http://www.perlmonks.org?node_id=781386


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.

Cheers,
Rob