www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 788] New: Compiler rejects hex floats in the format: HexPrefix HexDigits . HexDigits(opt) with binary-exponent-part required

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=788

           Summary: Compiler rejects hex floats in the format: HexPrefix
                    HexDigits . HexDigits(opt) with binary-exponent-part
                    required
           Product: D
           Version: 0.178
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid, spec
          Severity: normal
          Priority: P3
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: thecybershadow gmail.com


Spec: http://www.digitalmars.com/d/lex.html#floatliteral

Program:

void main()
{
  float f1 = 0x0.;
  float f2 = 0x1.5;
  float f3 = 0x.5;
}

Compiler output:

C:\...\bugs>dmd hexfloat.d
hexfloat.d(3): binary-exponent-part required
hexfloat.d(4): binary-exponent-part required
hexfloat.d(5): binary-exponent-part required


-- 
Jan 02 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=788






There is also another problem with HexFloat:

0x10f

Is this float (0x10)f, or double (0x10f)?

If, binary-exponent-part is really required, then spec is outdated, and there
is no problem:
0x10p0f       // float
0x10fp0       // double

"Hexadecimal floats are preceded with a 0x and the exponent is a p or P
followed by a decimal number serving as the exponent of 2."

so lexer grammar should be:

HexFloat:
        HexPrefix HexDigits . HexDigits HexExponent
        HexPrefix . HexDigits HexExponent
        HexPrefix HexDigits HexExponent


-- 
Jan 10 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=788






The hex exponent is required. I'll fix the doc.


-- 
Feb 02 2007