From: Ada novice <ycalleecharan@gmx.com>
Subject: understanding floating point types
Date: Sun, 22 Aug 2010 02:11:59 -0700 (PDT)
Date: 2010-08-22T02:11:59-07:00 [thread overview]
Message-ID: <74406fc1-f64b-4a3e-9dd6-301f1ed467ab@w30g2000yqw.googlegroups.com> (raw)
Hi,
I'm trying to understand the floating point representation in the
binary and decimal bases. If D is the number of decimal digits in the
mantissa, then the number if bits B is given by B = D(1og 10/1og 2) +
1 = 3.32 * D + 1 and this rounded up to the next integer value.
Thus for a float type in Ada, mantissa D = 6, then B = 3.32(6) +1 = 21
to the nearest upwards integer value. GNAT GPL 2010 shows that
Float'Mantissa is 21 bits.
Now the TOTAL number of bits in a float (Float'Size in GNAT GPL) is B
= 32 giving the range of exponent as -4B to 4B i.e. -128 to 128. And
this gives in decimal base a exponent (in Float'Last) of log(2^128)/
(log 10) = 38.53, which is 38 in GNAT GPL.
Now if I take the total number of bits for a float i.e. 32 and
subtract the number of bits for the mantissa (21), I get 11.
If I set 11 = 3.32(decimal equivalent) + 1, I get the unknown "decimal
equivalent" as 3 digits.
If I understand correctly, then 2 out of the 3 digits are for the
exponent. And what about the remaining 1 digit? Is it for a sign
before the mantissa or before the exponent?
I guess that I'm confusing between decimal and binary representations.
Some help would be highly appreciated :).
Thanks.
YC
next reply other threads:[~2010-08-22 9:11 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-22 9:11 Ada novice [this message]
2010-08-22 9:51 ` understanding floating point types 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
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