Mark Dickinson <dicki...@gmail.com> added the comment:

> Delphi uses the following code at initialization.

Yep.  That would explain the problem.  On x86 machines, Python's 
string-to-float and float-to-string conversions require that the x87 FPU has 
precision set to 53 bits rather than 64 bits (and also that the FPU rounding 
mode is round-half-to-even, but this rarely gets changed).

There's a configure-time check that works out whether resetting the precision 
is necessary;  if so, the precision is changed before each conversion and 
reverted again afterwards (see the _Py_SET_53BIT_PRECISION_START and 
_Py_SET_53BIT_PRECISION_END macros used in Python/pystrtod.c ).  It looks like 
you may need to override these macros for PyScripter.

Note that this isn't usually a problem on Windows:  the default setting on 
Windows is 53 bit precision;  I've no idea why Delphi changes it.  The main 
problem platform is 32-bit Linux, which uses 64-bit precision by default.  (And 
64-bit Linux generally uses the appropriate SSE2 instructions instead of the 
x87; these are always 53-bit precision.)

So in general there's an issue if the runtime FPU settings don't match the 
configure-time FPU settings.  I'm not sure what the best mechanism for solving 
this is.  Checking the FPU state before *every* conversion would be possible, I 
guess, but it most cases that's unnecessary.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue9980>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to