bug-glibc
[Top][All Lists]
Advanced

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

Re: Float problems with trunc() and round()


From: Andreas Schwab
Subject: Re: Float problems with trunc() and round()
Date: 03 Oct 2001 22:30:29 +0200
User-agent: Gnus/5.090003 (Oort Gnus v0.03) Emacs/21.0.107

Justin Guyett <address@hidden> writes:

|> On 3 Oct 2001, Andreas Schwab wrote:
|> 
|> > Kjeld Borch Egevang <address@hidden> writes:
|> >
|> >> I suppose the functions trunc() and round() should do something
|> >> similar to ceil() and floor(). When I try this on my i686-linux, it
|> >> seems to be broken. Here is my test:
|> >
|> > Your test is broken.
|> 
|> (glibc 2.2.4, i686-pc-linux-gnu, 2.4.9-ac3, gcc 2.95.3)
|> 
|> ---CUT---
|> #include <stdio.h>
|> #include <math.h>
|> 
|> int main(int argc, char **argv)
|> {
|>    printf("%f %f\n", truncf(1000.250), roundf(1000.501));
|>    return(0);
|> }
|> ---CUT---
|> 
|> % gcc -o t1 -lm test.c
|> % ./t1
|> 0.000000 2.086854
|> 
|> 
|> looks broken to me, but maybe i'm forgetting something

Yes, the test is *still* broken.  Learn to use -Wall.

gcc -O2 -g -Wall     round.c  -lm -o round
round.c: In function `main':
round.c:6: warning: implicit declaration of function `truncf'
round.c:6: warning: implicit declaration of function `roundf'
round.c:6: warning: double format, different type arg (arg 2)
round.c:6: warning: double format, different type arg (arg 3)

Andreas.

-- 
Andreas Schwab                                  "And now for something
address@hidden                          completely different."
SuSE Labs, SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5



reply via email to

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