comp.lang.ada
 help / color / mirror / Atom feed
From: Jacob Sparre Andersen <sparre@nbi.dk>
Subject: Re: understanding floating point types
Date: Tue, 24 Aug 2010 16:05:46 +0200
Date: 2010-08-24T16:05:46+02:00	[thread overview]
Message-ID: <87wrrgjebp.fsf@hugsarin.sparre-andersen.dk> (raw)
In-Reply-To: 59c78dcf-160f-458c-ae60-1e5562a9bff3@5g2000yqz.googlegroups.com

Ada novice <ycalleecharan@gmx.com> writes:

> I have just read the following from an Ada book by Fintan Culwin:
> ----
> type VeryAccurate is digits 16
> type NotAccurate is digits 2
>
> Values of the type VeryAccurate would have limited range with a high
> degree of precision. Values of the type NotAccurate would have a much
> greater range with only two digits of precision.
> ----
>
> My understanding is that using "B = 3.32*D + 1", a type with digits 16
> (D = 16) will have a higher B value and hence a higher exponent range
> -4*B to 4*B than a type with digits 2. Will a higher exponent range
> not give a higher range?
>
> What am I understanding wrong here?

You're using a random equation.

Fintan Culwin is probably assuming that you allocate a fixed number of
bits to represent a floating point number.  The fewer of those bits,
which are allocated to precision, the more can be allocated to the
exponent (and thus the range).

But in practice your compiler may choose exactly the same representation
for both of the types in the example above.

Greetings,

Jacob
-- 
"The same equations have the same solutions."



  reply	other threads:[~2010-08-24 14:05 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
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 [this message]
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