All good stuff Lundin. Also didn't know that about about the double.
I don't think that you can always assume correct "standard" implemntation of C though, and Microsoft, by any means, can't be considered the ultimate authority as they are just as quick to break the rules and make their own as the next guy...
I have found (shockingly) that there are times when the freescale compiler does stuff you don't normaly see (for example the testing of bit values and true vs. false vs. 0 vs. 0xfffffff
That said, looking back, I don't think we helped this guy yet.
He has done all the standard - good stuff -by testing it and even trying 0.0 but getting false results.
- The only thing we haven't told him to try is by using +0.0 or -0.0 or by using the ieee definition of zero (32 bit)( 0x0000 0000) instead which should totally solve his problem if the first two don't work.
He may have also oversimplified his example:
- Has anyone asked if he is using a global (or external) (variable a) and has the optimizations turned on (default)?
It could simply be if he doesn't change the variable within the scope of his test and the optimizer optimized it out (since he doesn't change the value here).
- Also, Done78, have you looked at the disassembly to verify that your test case 2 is even compiling?
You might have the warning "Removed Dead Code" which could clue you in to some undesired effects of optimization. You could also run by setting optimization to zero ( adding -O0 to the compile settings - thats an "Oh" Zero) or using the optimizations tab and selecting "disable optimizations"
Good luck, I hope this helps. Sorry I didn't read your earlier post about trying 0.0 with no luck.