[Numpy-discussion] Re ading scientific notation using D instead of E
Robert Kern
robert.kern at gmail.com
Fri Feb 12 11:12:17 EST 2010
On Fri, Feb 12, 2010 at 10:05, <josef.pktd at gmail.com> wrote:
> On Fri, Feb 12, 2010 at 11:03 AM, <josef.pktd at gmail.com> wrote:
>>>>> np.float('1.5698D+03')
>>
>> 1569.8
>>>>> np.float('1.23D+04')
>> 12300.0
>>
>> it's still working with numpy 1.4.0
>
> maybe this is a python feature with python builtin float:
>
>>>> float('1.5698D+03')
> 1569.8
>>>> float('123D+04')
> 1230000.0
>
> with python 2.5
numpy.float is indeed Python's builtin float type (for obscure
historical reasons that I won't go into). However, in Python 2.5, at
least, the parsing of the string is offloaded to the standard C
function strtod(). On your platform, strtod() will parse the D
correctly. On OS X, for example, it doesn't. It has nothing to do with
Python versions but rather the platform that you are on.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the NumPy-Discussion
mailing list