Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Jul 2004 21:06:32 +0400 (MSD)
From:      Dmitry Morozovsky <marck@rinet.ru>
To:        freebsd-hackers@freebsd.org
Subject:   gcc strangeness
Message-ID:  <20040711210219.J84500@woozle.rinet.ru>

next in thread | raw e-mail | index | archive | help
Dear colleagues,

one of my friends has raisen very strange issue regarding gcc rounding:

marck@woozle:/tmp/tsostik> uname -r
4.10-STABLE
marck@woozle:/tmp/tsostik> gcc -v
Using builtin specs.
gcc version 2.95.4 20020320 [FreeBSD]

marck@woozle:/tmp/tsostik> cat x.c
#include <stdio.h>
int main ()
{
        float a;
        for(a=0.01;a<=0.1; a+=0.01)
          printf("%f %.3f %d\n", a*100, a*100, (int)(a*100));
return 0;
}
marck@woozle:/tmp/tsostik> cc x.c
marck@woozle:/tmp/tsostik> ./a.out
1.000000 1.000 0
2.000000 2.000 1
3.000000 3.000 2
4.000000 4.000 3
5.000000 5.000 5
6.000000 6.000 6
7.000000 7.000 7
8.000000 8.000 7
9.000000 9.000 8
9.999999 10.000 9

Any comments?


Sincerely,
D.Marck                                     [DM5020, MCK-RIPE, DM3-RIPN]
------------------------------------------------------------------------
*** Dmitry Morozovsky --- D.Marck --- Wild Woozle --- marck@rinet.ru ***
------------------------------------------------------------------------



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040711210219.J84500>