This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

strange i386 floating point behavior



where 

int i = 1000;
double r = 0.35999999999999999;

and

int i1;
double r1;

on Linux the statement

i1 = r1 = i*r;
printf("%d,%g\n",i1,r1);

/* this prints 359,360 */
gives different answers than

r1 = i*r;
i1 = r1;
printf("%d,%g\n",i1,r1);

/* this prints 360,360 */
when on sun, hp, etc these give the same answer.
/* 360,360 */

this is on 
egcs-2.91.66

Am I just doing something stupid or is there something
wrong somewhere?  I can certainly provide more
information if that would help.

merimus@yahoo.com


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]