Simon <> writes:
> I looked over the C99 spec for hexadecimal constants. They seem quite
> odd on two accounts. For one, it is a binary exponent value, but the
> other number is hexadecimal. Why not make them both hexadecimal? You
> really don't lose anything...you just have to shift your radix point a
> bit. This just seems confusing as it is.
I have always assumed that hexadecimal constants were written in
hexadecimal instead of binary just to save space. That is, the
underlying representation of floating-point numbers is assumed to
be in base 2, and one writes those in base 16 just to avoid
making the textual representation very long.
> The other is even stranger. The binary exponent value is actually
> represented in decimal. What is decimal doing here? Isn't it
> satisfied already being the only choice so far even though it
> introduces round off errors and results in a less elegant compiler
> implementation? Decimal is like a virus that decays elegance,
> simplicity, and happiness.
Representing the exponent in decimal doesn't introduce any
round-off errors, and it's easier for humans to read and
understand than representing it in binary or hexadecimal.
--
Ben Pfaff
http://benpfaff.org