Prev: Dhrystone
Next: Learning Ada
From: Ada novice on 6 Aug 2010 05:11 On Aug 5, 10:25 pm, Simon Wright <si...(a)pushface.org> wrote: > > The attached update uses fixed notation, looks rather better. Thanks for the revised code Simon. YC
From: Ada novice on 6 Aug 2010 05:17 On Aug 5, 7:59 pm, Jeffrey Carter <spam.jrcarter....(a)spam.not.acm.org> wrote: > > You requested 15 decimal digits; your results are zero to 15 decimal places. If > you output in non-scientific notation you'd get zero; presumably that's what > Matlab is doing. > Thanks. This makes sense. Matlab is using decimal notation and works to 15 digits of precision. Hence we won't see when the most significant digit has power "e-17" say in scientific notation. YC
From: Ada novice on 6 Aug 2010 05:26 On Aug 6, 10:42 am, "Dmitry A. Kazakov" <mail...(a)dmitry-kazakov.de> wrote: > Further, practically you should never use subtype in the form > > subtype My_Float is Long_Float; > > except for special cases like: > > subtype Non_IEEE_Float is Long_Float range Long_Float'Range; > > or > > subtype Non_Negative_Float is Long_Float range 0.0..Long_Float'Last; Thanks. Why is subtype My_Float is Long_Float not proper? Is it because it's a subtype and not a parent type? Because we haven't specified what's the parent type is and a subtype is only a parent type with a limited range. So this is why subtype Non_Negative_Float is Long_Float range 0.0..Long_Float'Last; as you wrote makes sense I guess as we are limiting the range? What about "type My_Float is digits 18" as Jacob Sparre Andersen said in an earlier message? This is not a subtype and should be theoretically proper. Am I right? But sjw in an earlier message mentions that the "internals of the matrix operations only use 64 bits. So in any case then asking for more than Long-Float precision is not "relevant". YC
From: Peter Hermann on 6 Aug 2010 05:49 Jacob Sparre Andersen <jacob(a)jacob-sparre.dk> wrote: > type My_Float is digits 18; 14 will run everywhere, 18 not. ph
From: Dmitry A. Kazakov on 6 Aug 2010 05:51
On Fri, 6 Aug 2010 02:26:22 -0700 (PDT), Ada novice wrote: > On Aug 6, 10:42�am, "Dmitry A. Kazakov" <mail...(a)dmitry-kazakov.de> > wrote: >> Further, practically you should never use subtype in the form >> >> � �subtype My_Float is Long_Float; >> >> except for special cases like: >> >> � �subtype Non_IEEE_Float is Long_Float range Long_Float'Range; >> >> or >> >> � �subtype Non_Negative_Float is Long_Float range 0.0..Long_Float'Last; > > Thanks. Why is subtype My_Float is Long_Float not proper? Is it > because it's a subtype and not a parent type? Because it does not tell anything about My_Float. When you declare a subtype you should have a reason for it. The only reason is putting a constraint on it. (Another might be type renaming, but that is an Ada kludge) > What about "type My_Float is digits 18" as Jacob Sparre Andersen said > in an earlier message? If you wanted a type of defined accuracy. It depends on what you want to achieve: 1. Constraining -> Subtype 2. Requiring certain accuracy/precision -> Type 3. Interfacing -> A type from some library package like Interfaces.C 4. Separation of domains (e.g. measurement units etc) -> Type 5. Type extension, reimplementation -> type T is private; and in the private part: type T is new Float; > But sjw in an earlier message > mentions that the "internals of the matrix operations only use 64 > bits. So in any case then asking for more than Long-Float precision is > not "relevant". That would be the case 3. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de |