I\'m getting unexpected results from the round()
and roundf()
functions in the math.h
library. Here is the sample code:
#
To add to the chorus of approvals, this works fine for me (OS X Leopard using gcc).
Out of curiosity, do you need to use the -lm
flag? I didn't the first time, and I did the second time, and there was no difference, but that's because libm.dylib and libc.dylib are symbolic links to the same library on OS X. Perhaps your libm is broken or something? Do you need to link to libm or not? I would think that the math.h functions would be part of libc...?
EDIT:
Before you do any of that, try using this instead:
float f = 0;
double d = 0;
I don't think that should change anything, but if it does, I win.