A
andrew.mackeith
When formatting a float using the exponential format, the rounding is different in Python-2.6 and Python-2.7. See example below.
Is this intentional?
Is there any way of forcing the Python-2.6 behavior (for compatibility reasons when testing)?
Python 2.6.5 (r265:79096, Mar 19 2010, 18:02:59) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
....
2.096732130e+02 2.0967321e+02
2.096732140e+02 2.0967321e+02
2.096732150e+02 2.0967322e+02 <<<<<<<<
2.096732151e+02 2.0967322e+02
4.096732160e+00 4.0967322e+00.... print '%.9e %.7e'%(-a,-a)
....
-2.096732130e+02 -2.0967321e+02
-2.096732140e+02 -2.0967321e+02
-2.096732150e+02 -2.0967322e+02 <<<<<<<<
-2.096732151e+02 -2.0967322e+02
-4.096732160e+00 -4.0967322e+00
Type "help", "copyright", "credits" or "license" for more information.
....
2.096732130e+02 2.0967321e+02
2.096732140e+02 2.0967321e+02
2.096732150e+02 2.0967321e+02 <<<<<<<<
2.096732151e+02 2.0967322e+02
4.096732160e+00 4.0967322e+00.... print '%.9e %.7e'%(-a,-a)
....
-2.096732130e+02 -2.0967321e+02
-2.096732140e+02 -2.0967321e+02
-2.096732150e+02 -2.0967321e+02 <<<<<<<<
-2.096732151e+02 -2.0967322e+02
-4.096732160e+00 -4.0967322e+00Andrew MacKeith
Is this intentional?
Is there any way of forcing the Python-2.6 behavior (for compatibility reasons when testing)?
r:\asiData\abaObjects\lib>c:\python26\pythonc:\python26\python
Python 2.6.5 (r265:79096, Mar 19 2010, 18:02:59) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
.... print ' %.9e %.7e'%(a,a)x = [2.096732130e+02,2.096732140e+02,2.096732150e+02,2.096732151e+02,2.096732160+02]
for a in x:
....
2.096732130e+02 2.0967321e+02
2.096732140e+02 2.0967321e+02
2.096732150e+02 2.0967322e+02 <<<<<<<<
2.096732151e+02 2.0967322e+02
4.096732160e+00 4.0967322e+00.... print '%.9e %.7e'%(-a,-a)
....
-2.096732130e+02 -2.0967321e+02
-2.096732140e+02 -2.0967321e+02
-2.096732150e+02 -2.0967322e+02 <<<<<<<<
-2.096732151e+02 -2.0967322e+02
-4.096732160e+00 -4.0967322e+00
Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on win32c:\python27\python
Type "help", "copyright", "credits" or "license" for more information.
.... print ' %.9e %.7e'%(a,a)x = [2.096732130e+02,2.096732140e+02,2.096732150e+02,2.096732151e+02,2.096732160+02]
for a in x:
....
2.096732130e+02 2.0967321e+02
2.096732140e+02 2.0967321e+02
2.096732150e+02 2.0967321e+02 <<<<<<<<
2.096732151e+02 2.0967322e+02
4.096732160e+00 4.0967322e+00.... print '%.9e %.7e'%(-a,-a)
....
-2.096732130e+02 -2.0967321e+02
-2.096732140e+02 -2.0967321e+02
-2.096732150e+02 -2.0967321e+02 <<<<<<<<
-2.096732151e+02 -2.0967322e+02
-4.096732160e+00 -4.0967322e+00Andrew MacKeith