Hex floats

Stewart Gordon smjg_1998 at yahoo.com
Wed Feb 15 16:47:56 PST 2012


On 15/02/2012 21:33, H. S. Teoh wrote:
> On Wed, Feb 15, 2012 at 01:24:13PM -0800, H. S. Teoh wrote:
> [...]
>> This is ambiguous, since you could interpret 0xFFp0F as either 0xFFp0
>> followed by the suffix 'F', or 0xFFp0F with an exponent of 0x0F no
>> suffix.
> [...]
>
> Actually, nevermind that. I misread the specs; the exponent is always in
> decimal, not hex, so this case is actually unambiguous.

Maybe that's the reason for requiring the exponent - to render the F unambiguous.

Though it could be done by defining the grammar such that the exponent is optional but the 
F suffix is allowed only after an exponent.  But I wonder whether, if it's done that way, 
many people will inadvertently try to use F as a suffix to an exponentless HexFloat.  So 
requiring an exponent might be to protect against this mistake.

Up until another person makes the mistake of assuming the exponent of a HexFloat is meant 
to be hexadecimal....

Stewart.


More information about the Digitalmars-d-learn mailing list