www.digitalmars.com         C & C++   DMDScript  

c++ - Bug? Comparison of doubles involving long double

reply robertschlicht yahoo.com writes:
I am using DMC version 8.38 on Win32. The 
result of comparing two doubles seems to 
get wrong sometimes when a long double and 
the ?: operator are involved. Maybe I am 
wrong, but I think the following code 
should return 0, not 1. 

Thanks in advance for any suggestions.


#include <stdio.h>
#include <math.h>

int main(void)
double x, y;
long double z;

x = sqrt(1);
y = sqrt(2);
z = 0;

printf("y > x, so the return value should be zero (false). It isn't.");

return y < (1? x : z);
Dec 03 2003
parent "Walter" <walter digitalmars.com> writes:
Looks like a bug. I'll take it from here. Thanks, -Walter
Dec 05 2003