I\'m getting unexpected results from the round()
and roundf()
functions in the math.h
library. Here is the sample code:
#
When I compile and run this exact code (under gcc on cygwin) I get:
$ ./a.exe
1.000000
1.000000
How new is your compiler? A compiler bug is all I can think of, as gcc -Wall
gives no warnings either.
To add some further information this forum thread seems to show changing compiler to a newer version fixes it. If this doesn't work for you you'll need to give more details of compiler and OS, but given this seems to work for other people on three different platforms looks like your compiler is at fault.