On 4/09/2007 7:13 AM, Doug Currie wrote:
On Monday, September 03, 2007 Nuno Lucas wrote:
Maybe some OS specific error? Wasn't there some discussion earlier
about the Microsoft compiler not using the full double precision by
default?

Microsoft C compilers store long doubles in 64 bits, just like
doubles http://msdn2.microsoft.com/en-us/library/9c3yd98k(VS.80).aspx
whereas gcc stores long doubles in 96 bits and uses 64 bit mantissa
(80x87 "extended" type) versus Microsoft 53 bit mantissa.
http://msdn2.microsoft.com/en-us/library/9cx8xs15(vs.80).aspx

Sqlite3 uses long doubles in round, and other functions, and so
results between Microsoft Visual C++ compiled and gcc compiled
versions of sqlite3 are bound to produce different results.

"different" means wrong, even if only by 1 ulp.

A correct answer should be achievable with 64-bit FP. The Windows distribution of Python is compiled with an MS C compiler; it manages to get the correct answer for Selena's test cases. The source for round() is trivially small, platform-independent, and just uses doubles. It relies on the C library floor() function (ceil() if negative). Rounding a positive number f to 2 decimal places is effectively as simple as floor(f * 100.0 + 0.5) / 100.0 ... worth borrowing, perhaps.



-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to