Am Freitag 11 Februar 2011, 20:48:58 schrieb Misha Koshelev:
- if (*((unsigned int *)&in) == 0x00000000) return 0x0000;
- if (*((unsigned int *)&in) == 0x80000000) return 0x8000;
Thinking about it, there's something about this line that is not so nice: It relies on the actual encoding of the float, which may technically be platform specific if there's a CPU that implements non-IEEE- 754 floats.
You could try something like this(pseudo code, I removed the *s)
if(in == 0.0) { if(sign(1.0 / in) == positive) return 0x0000; else return 0x8000; }
The idea is that 1.0 / 0.0 returns Inf and 1.0 / -0.0 -Inf. I may be mistaken about that though.