Red Hat Bugzilla – Bug 67216
round function does not work
Last modified: 2007-04-18 12:43:26 EDT
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Charter B1)
Description of problem:
The round() function (and other similar rounding functions) do not work. (I
The following gives me a zero result:
/* dnum would be 0*/
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1.Program above with or without optimization
Actual Results: When using round I get 0, huge numbers or NAN
round(3) is only part of ISO C99, so you need to select that feature
set or language standard when compiling, like:
gcc -std=c99 round.c -lm
gcc -D_ISOC99_SOURCE round.c -lm
gcc -D_GNU_SOURCE round.c -lm
If you compiled the program with -Wall (and without one of the above options),
you'd see what's going on clearly:
warning: implicit declaration of function `round'
See info libc, "Feature Test Macros" chapter.
Thanks, that worked. Without it, it was stomping all over memory. Will use
the -Wall feature from now on.