From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: understanding floating point types
Date: Sun, 22 Aug 2010 21:34:41 +0200
Date: 2010-08-22T21:34:39+02:00 [thread overview]
Message-ID: <7mcl3j29wtw1.xle9n3lvga8c.dlg@40tude.net> (raw)
In-Reply-To: 2d2a622b-6c4a-45b7-9e3c-a565d5dbc9e3@p3g2000yqp.googlegroups.com
On Sun, 22 Aug 2010 12:05:33 -0700 (PDT), Ada novice wrote:
> 1. You used: type My_Float is digits 3; I tend to confuse the fact
> that digits 3 means 3 digits of precision after the decimal point? So
> when I consider 2.33 or 3.45, then both numbers are with digits 2 in
> my mind. Or does digits 3 mean 3 significant digits which will include
> the leading 2 in 2.33 and the leading 3 in 3.45 as well?
Yes, it is relative, in the case of floating-point numbers. Ada has another
model of real numbers, the fixed point numbers, they have an absolute
precision.
> 2. In your example, you have:
>
> Model view: 8.04E+00
> The reality: 8.03850E+00
>
> If I understand correctly, model view represents the number that is
> exactly representable by the computer.
Yes, the model number is your requirement. The machine number is an
implementation that fulfills your requirement.
> In our case here, we can get
> the reality number since Float has higher precision digits than
> My_Float. However if My_float used the same precision digits as Float
> (i.e. 6) then this would also represent the number that could be
> represented by the computer. If both a and b had a hypothetical 30
> digits of precision, then neither Float (6 digits) nor Long_Float (15
> digits), nor Long_Long_Float (18 digits) would give the right value
> that would represent the model number of the multiplication result
> a*b.
Neither they would a or b. 30 digits precision require 101 bits of machine
mantissa.
> I mentioned the word hypothetical, as we would not able to use a
> number with 30 digits of precision anyway on a computer. But my point
> was to say that Model view doesn't have to have less precision digits
> as the reality number.
The machine number precision must be equal or greater than the model one.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2010-08-22 19:34 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-22 9:11 understanding floating point types Ada novice
2010-08-22 9:51 ` Dmitry A. Kazakov
2010-08-22 10:37 ` Ada novice
2010-08-22 10:39 ` Ada novice
2010-08-22 13:57 ` Dmitry A. Kazakov
2010-08-22 17:15 ` Ada novice
2010-08-22 18:16 ` Dmitry A. Kazakov
2010-08-22 19:05 ` Ada novice
2010-08-22 19:34 ` Dmitry A. Kazakov [this message]
2010-08-23 6:29 ` Ada novice
2010-08-23 6:40 ` J-P. Rosen
2010-08-23 7:13 ` Dmitry A. Kazakov
2010-08-23 7:15 ` Martin
2010-08-23 11:42 ` Ada novice
2010-08-24 12:14 ` Ada novice
2010-08-24 14:05 ` Jacob Sparre Andersen
2010-08-24 14:36 ` Ada novice
2010-08-22 17:22 ` Yannick Duchêne (Hibou57)
2010-08-22 18:49 ` Ada novice
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox