Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I read up a bit more on floating point handling in C99 onwards (don't know about C89, I misplaced my copy of the standard) and expressions are allowed to be contracted unless disabled with the FP_CONTRACT pragma. So again, this is entirely within the bounds of what the C standard explicitly allows and as such if you need stronger guarantees about the results of floating point operations you should disable expression contraction with the pragma in which case, (from further reading) assuming __STDC_IEC_559__ is defined, the compiler should strictly conform to the relevant annex.

Anyone who regularly works with floating point in C and expects precision guarantees should therefore read that relevant portion of the standard.



"Strictly conforming" has a specific meaning in the standard, including that all observable outputs of a program should not depend on implementation defined behavior like the precision of floating point computations.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: