What the hell is going on? Just a simple division...

Paul E.C. Melis melis@cs.utwente.nl
Tue Dec 21 13:14:00 GMT 1999


/*
Using gcc-2.95.2 and linux 2.0.35 (libc5) the
following program gives as output
    0
    1
instead of the obviously correct output
    1
    1
Is this a compiler bug?
I have a Celeron 333 by the way. /proc/cpuinfo
reports that it doesn't have an fdiv bug.
Paul (melis@cs.utwente.nl)
*/

#include <math.h>
#include <stdio.h>

int main (int argc, char *argv[])
{
    printf ("%d\n", (int) ( log(2.0) / log(2.0) ));
    printf ("%d\n", (int) ( log10(2.0) / log10(2.0) ));
}





More information about the Gcc-help mailing list