Circumspect programming (was: Evaluation of if's)
Chris Torek
torek at elf.ee.lbl.gov
Wed Jun 26 07:35:59 AEST 1991
In article <1991Jun24.202840.26091 at arcturus.uucp> berry at arcturus.uucp
(Berry;Craig D.) writes:
>... I recall reading an article somewhere ... on the semantics of C
>under ANSI standard floating point operations.
ANSI C says little about floating point operations (it leaves a lot of
details up to the implementor, and no doubt leaves others undefined; it
*does* constrain implementors to use binary representations).
>One point raised was that ANSI C specifically removes the requirement
>for "knothole" casts to floats; e.g., if you have an 80-bit value in a
>floating point register, and you cast it to double ... the extra 16
>bits (assuming 64-bit doubles) are *not necessarily* scraped off by
>the cast. This could [a]ffect the value of something like
>a * (double) (b + c).
This is correct (except that `specifically removes' is overstating the
case).
>Now, assignment to a double *does* scrape off the excess bits, by definition.
This is not correct. The C standard does not say if or when `extra'
precision vanishes. This is sometimes problematical.
--
In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 415 486 5427)
Berkeley, CA Domain: torek at ee.lbl.gov
More information about the Comp.lang.c
mailing list