Thread overview
Re: Hex floats
Feb 15, 2012
H. S. Teoh
Feb 16, 2012
Stewart Gordon
Feb 16, 2012
H. S. Teoh
Feb 16, 2012
Timon Gehr
February 15, 2012
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.


T

-- 
In theory, there is no difference between theory and practice.
February 16, 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.
February 16, 2012
More questions about hex floats. So we've established that hex floats have decimal exponents. So how should the following be tokenized?

	0x1p1E8

Should it be tokenized as (Float: 0x1p1)(Identifier: E8), or should it
be an error?


T

-- 
Не дорог подарок, дорога любовь.
February 16, 2012
On 02/16/2012 08:36 PM, H. S. Teoh wrote:
> More questions about hex floats. So we've established that hex floats
> have decimal exponents. So how should the following be tokenized?
>
> 	0x1p1E8
>
> Should it be tokenized as (Float: 0x1p1)(Identifier: E8), or should it
> be an error?
>
>
> T
>

It should be tokenized into the two tokens. q{0x1p1E8} is a legal D token.