March 06, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=21

           Summary: unexpected results for: double -> real with value
                    1.7976931348623157e+308
           Product: D
           Version: 0.148
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P3
         Component: DMD
        AssignedTo: walter@digitalmars.com
        ReportedBy: thomas-dloop@kuehne.cn


Porting from C to D.

== test.c ==
# #include <assert.h>
#
# int main(){
#     double d = 1.7976931348623157e+308;
#     long double ld = d;
#
#     assert(ld == 1.7976931348623157e+308);
#
#     return 0;
# }

== test.d ==
# int main(){
#     double d = 1.7976931348623157e+308;
#     real ld = d;
#
#     assert(ld == 1.7976931348623157e+308);
#
#     return 0;
# }

test results:

==C code (64 bit mode)==
[PASS]
double:      0xFFFFFFFFFFFFEF7F
long double: 0x00F8FFFFFFFFFFFFFE43400000000000

==C code (32 bit mode)==
[PASS]
double:      0xFFFFFFFFFFFFEF7F
long double: 0x00F8FFFFFFFFFFFFFE43FFFF

==D code (32 bit mode)==
[FAIL]
double: 0xFFFFFFFFFFFFEF7F
real:   0x00F8FFFFFFFFFFFFFE430000

test cases:
http://dstress.kuehne.cn/run/d/double_28_A.d
http://dstress.kuehne.cn/run/d/double_28_B.d


-- 

March 06, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=21


walter@digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




------- Comment #1 from walter@digitalmars.com  2006-03-06 14:06 -------
This is not a bug. D always tries to do any compile time evaluation of floating point constants at max precision. So, you can get different results by assigning the same literal to a double than if it is assigned to a real. The assignment to double rounds the literal to double precision, the assignment to real rounds it to real precision.


--