Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^2: [Win32, C, and way OT] C floats, doubles, and their equivalence

by syphilis (Chancellor)
on Jul 19, 2009 at 00:12 UTC ( #781386=note: print w/replies, xml ) Need Help??

in reply to Re: [Win32, C, and way OT] C floats, doubles, and their equivalence
in thread [Win32, C, and way OT] C floats, doubles, and their equivalence

It's a stab in the dark ...

Good stab - I can make use of that. The following outputs "True False" on the buggy compilers (and "True True" on sane compilers):
#include <stdio.h> int main(void) { double nv = 2.0 / 3; float foo = 2.0 / 3; float truncated = (float)nv; if(foo == truncated) printf("True "); else printf("False "); if(foo == (float)nv) printf("True\n"); else printf("False\n"); return 0; }
I can apply that method (used to obtain that "True") to PDL, which solves the problem I have asked about. Unfortunately, while it enables me to get the behaviour I want with my C demo scripts, it's still not producing the correct result with PDL - but this is such a fickle bug. I'll have to play around with it some more.

PS: This is relevant to the work I do ensuring Windows compatibility for my XS distros

#if defined _MSC_VER && _MSC_VER < 1400 then expect weirdness if you start comparing floats with doubles.

Thanks Marvin.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://781386]
NodeReaper stumbles on his way to the attic

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (10)
As of 2017-02-28 15:55 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (405 votes). Check out past polls.