--- [EMAIL PROTECTED] wrote: > Going into this statement on both Linux and Windows, > the exact same values are in realvalue and in rounder: > > realvalue: 0xf333333333333000 0.94999999999999995559107901499373838 > rounder: 0x3fa999999999999a 0.05000000000000000300000000000000000 > > Both machines execute the exact same 4 ix86 opcodes: > > fldl <address of rounder> > fldt <address of realvalue> > faddp %st,%st(1) > fstpt <address of realvalue> > > But they end up with different answers. Linux gets > what I believe is the correct answer: > > realvalue: 0xfffffffffffffd00 0.99999999999999995836663657655662973 > > Windows gets the wrong answer: > > realvalue: 0x8000000000000000 1.00000000000000000000000000000000000 > > Can somebody please suggest to me what the difference is? > Does windows somehow initialize the floating point hardware > differently so that it does some kind of rounding on its own? > Why should the same machine-language instructions generate a > different answer on windows than it does on linux?
http://support.microsoft.com/kb/102555 Microsoft Visual C++ runtime library provides default floating-point exception handling and includes functions such as _controlfp for determining and adjusting the floating-point hardware's rounding, precision control, and exception handling behavior. More info on fp:precise and _controlfp: http://msdn2.microsoft.com/en-us/library/aa289157(vs.71).aspx double a, b, cLower, cUpper; . . . _controlfp( _RC_DOWN, _MCW_RC ); // round to -∞ cLower = a*b; _controlfp( _RC_UP, _MCW_RC ); // round to +∞ cUpper = a*b; _controlfp( _RC_NEAR, _MCW_RC ); // restore rounding mode ____________________________________________________________________________________ Now that's room service! Choose from over 150,000 hotels in 45,000 destinations on Yahoo! Travel to find your fit. http://farechase.yahoo.com/promo-generic-14795097 ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------

