should double have better precision or greater range?

Barnacle Wes wes at obie.UUCP
Fri Sep 16 14:31:59 AEST 1988


In article <8809061831.AA29128 at ucbvax.Berkeley.EDU>, U23405 at UICVM (Michael J. Steiner) writes:
> I may go as far as to say that there should be two kinds of doubles, one
> with better precision and another with greater range. They could be called
> something like "acdouble" and "widouble" standing for "accurate double"
> and "wide double" respectively.

Actually, there ARE two kinds of doubles: D_floating and G_floating.
D_floating is a 64-bit format with 1 sign bit, 8 bit exponent excess
128, and 56-bit normalized fraction.  The range of D_floating is
0.29e-38 to 1.7e38, with approximately 16 decimal digits of precision.
G_floating is a 64-bit format with 1 sign bit, 11 bit exponent excess
1024 (!), and 53-bit normalized fraction.  The range of G_floating is
0.56e-308 to 0.9e308, with approximately 15 decimal digit precision.
These are, of course, VAX floating-point formats.

> I can't really choose between the two
> because whether a programmer would want to use an accurate double or a wide
> double would depend on what kind of application he is doing.

With most VAX compilers, you don't have to choose one or the other, you
can get both.  If your system supports G_floating, that is.  The
MicroVAX doesn't, I think it just uses D_floating if you ask for
G_floating.

> Also, I recently heard of a "long double". Since double is defined as
> "long float", this would mean "long long float", which is confusing.

Yup.  This is called H_floating.  Surpised?  I thought not.  H_floating
is a 128-bit format with 1 sign bit, 15 bit exponent excess 16384 (!!!),
and a 113-bit normalized fraction.  The range of H_floating is
0.84e-4932 to 0.59e4932, and the precision is typically 33 decimal
digits!!!

> As far as I know, C doesn't allow this. (It would be nice, though, to make
> a data type as long as you want by saying "long long long long ... <type>")
> Anyone hear about this?

I think VAX C has some way of support the "other" floating point
standards, but of course, that's a somewhat weird compiler.  When in
Rome, etc....

-- 
                     {hpda, uwmcsd1}!sp7040!obie!wes

         "How do you make the boat go when there's no wind?"
                                 -- Me --



More information about the Comp.lang.c mailing list