bug-glibc
[Top][All Lists]
Advanced

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

Float problems with trunc() and round()


From: Kjeld Borch Egevang
Subject: Float problems with trunc() and round()
Date: Wed, 3 Oct 2001 13:28:47 +0200 (CEST)

I discovered what I assume to be a problem.

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:

#include <math.h>

int main()
{
    float x;

    x = 4.0/3;
    printf("%e %e %e %e %e\n", x, floor(x), ceil(x), trunc(x), round(x));
}

it prints out:

1.333333e+00 1.000000e+00 2.000000e+00 1.112537e-308 -1.997559e+00

I use glibc-2.2-9 but the same problem exists in glibc-2.2.4.


/Kjeld

-- 
_    _ ____  ___                       Mailto:address@hidden
|\  /|||___)(___    MIPS Denmark       Direct: +45 44 86 55 85
| \/ |||    ____)   Lautrupvang 4 B    Switch: +45 44 86 55 55
  TECHNOLOGIES      DK-2750 Ballerup   Fax...: +45 44 86 55 56
                    Denmark            http://www.mips.com/




reply via email to

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