[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trunc and Round in GLIBC

From: Andreas Schwab
Subject: Re: Trunc and Round in GLIBC
Date: Tue, 24 Sep 2002 23:25:32 +0200
User-agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.3.50 (ia64-suse-linux)

"Dhiraj Sharma" <address@hidden> writes:

|> I am running into anomalous behavior of trunc() and round() on Red Hat 7.3 
(no changes made from my side at all) running on an Intel Pentium CPU. The 
following program gives me two numbers, both 0.
|> #include <stdio.h>
|> #include <math.h>
|> int main() {
|>    printf("%f\n", trunc(2.1);
|>    printf("%f\n", round(2.1);
|> }
|> If I use truncf and roundf, I get some random numbers. Other functions, such 
as, rint, floor, ceil give expected results. 
|> If I am doing something wrong, it is totally unknown to me. I would 
appreciate help in this regard. Thank you very much in advance.

Try "gcc -Wall", it will tell you that trunc and round are implicitly
defined.  You need to define _ISOC99_SOURCE (or _GNU_SOURCE), *note
(libc)Feature Test Macros::.


Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

reply via email to

[Prev in Thread] Current Thread [Next in Thread]