comp.lang.ada
 help / color / mirror / Atom feed
From: Ada novice <ycalleecharan@gmx.com>
Subject: Re: understanding floating point types
Date: Tue, 24 Aug 2010 07:36:22 -0700 (PDT)
Date: 2010-08-24T07:36:22-07:00	[thread overview]
Message-ID: <1b2df04a-c1db-4498-8eca-e82e96818600@f42g2000yqn.googlegroups.com> (raw)
In-Reply-To: 87wrrgjebp.fsf@hugsarin.sparre-andersen.dk

On Aug 24, 4:05 pm, Jacob Sparre Andersen <spa...@nbi.dk> wrote:
> Ada novice <ycalleecha...@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."

I was thinking the same regarding having "limited" number of bits
available but wasn't sure. Thanks for the confirmation. Maybe what he
is saying applies more to the embedded programming way of thinking.

YC



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