www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8523] New: compile time parsing of hex floats

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

           Summary: compile time parsing of hex floats
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: ellery-newcomer utulsa.edu



12:55:19 PDT ---
doesn't work, but should.

enum string s = "0x9.D70A3D70A3D70A4p-3";
enum d2 = to!real(s);
pragma(msg, d2);

gives me:

/usr/include/dmd-d/std/conv.d(2305): Error: Cannot convert &real to long* at
compile time
/usr/include/dmd-d/std/conv.d(1592):        called from here: parse(value)
/usr/include/dmd-d/std/conv.d(268):        called from here: toImpl(_param_0)
test.d(14):        called from here: to("0x9.D70A3D70A3D70A4p-3")
/usr/include/dmd-d/std/conv.d(2305): Error: Cannot convert &real to long* at
compile time
/usr/include/dmd-d/std/conv.d(1592):        called from here: parse(value)
/usr/include/dmd-d/std/conv.d(268):        called from here: toImpl(_param_0)
test.d(15):        called from here: to("0x9.D70A3D70A3D70A4p-3")
to("0x9.D70A3D70A3D70A4p-3")

however,

double d = to!real(s);
writeln(d);

compiles and prints

1.23

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 08 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8523


Peter Alexander <peter.alexander.au gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |CTFE
                 CC|                            |peter.alexander.au gmail.co
                   |                            |m
            Summary|compile time parsing of hex |[CTFE] compile time parsing
                   |floats                      |of hex floats



12:03:21 PST ---
Added CTFE tag. I don't think there's any sane way to do this without CTFE
support for the pointer cast, or at least unions.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 05 2013