From: "Plato" <zhangguoqiang@xunlei.com>
To: linux-c-programming <linux-c-programming@vger.kernel.org>
Subject: Why does math.h not declare function round?
Date: Mon, 24 Sep 2007 12:10:07 +0800 [thread overview]
Message-ID: <200709241210070352829@xunlei.com> (raw)
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
next reply other threads:[~2007-09-24 4:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-24 4:10 Plato [this message]
2007-09-24 7:10 ` Why does math.h not declare function round? Steve Graegert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200709241210070352829@xunlei.com \
--to=zhangguoqiang@xunlei.com \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.