Skip to contentSkip to conversation

Why does math.h not declare function round?

DISCUSSION 이종민 1 participant 1 message May 14, 2008

lore
Share & tools
lore

이종민

author
#0 lore raw

-----Original Message-----
From: [email protected] [mailto:linux-c-programming- [email protected]] On Behalf Of Plato
Sent: Monday, September 24, 2007 1:10 PM
To: linux-c-programming
Subject: Why does math.h not declare function round?

Hi!
I made such a program foo.c:

#include <math.h>

int main()

{
    double bar=1.2;
    printf("%f\n", round(bar));
}

Then compile and run:
[root@so41 tmp]# gcc foo.c -ofoo -lm
[root@so41 tmp]# ./foo
0.000000

The result was obviously wrong. Then I add statement:
#include <math.h>
double round(double x);

int main()

{
    double bar=1.2;
    printf("%f\n", round(bar));
}

Then compile and run:
[root@so41 tmp]# gcc foo.c -ofoo -lm
[root@so41 tmp]# ./foo
1.000000

Now it's right.

I wonder why function round not declared in math.h. Anyone have idea?

Thx.

Plato
2007-09-24

-
To unsubscribe from this list: send the line "unsubscribe linux-c- programming" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html