On architectures that support IEEE 754 float representation, a common trick to
quickly cast an unsigned long val to a float in the range [0, 1) is the following:
unsigned long temp = (val & 0x07fffff) | 0x3f800000;
return *((float *)&temp) - 1.0f;
With gcc 4.0.1 using -O2 optimization this trick no longer seems to work.
Created attachment 9502 [details]
stand-alone c example program
The file contains a failing "frand32" function and a workaround using a union.
Yes because you are violating C aliasing rules.
*** This bug has been marked as a duplicate of 21920 ***