Convert a scientific notation to decimal number, and still keeping the data format as float64

Thomas Jollans tjol at tjol.eu
Fri Oct 18 06:47:22 EDT 2019


On 18/10/2019 10:35, doganadres at gmail.com wrote:
> Here is my question:
>
>
> I am using the numpy.std formula to calculate the standart deviation. However, the result comes as a number in scientific notation.
> Therefore I am asking, How to convert a scientific notation to decimal number, and still keep the data format as float64 ?
>
> Or is there any workaround to get the initial standart deviation result as a decimal number?
>
>
> Here is my code:
>
> stdev=numpy.std(dataset)
> print(stdev)
>      Result: 4.999999999999449e-05
>
>
> print(stdev.dtype)
>      Result: float64
>
>
> Solutions such as this:
>
> stdev=format(stdev, '.10f')
> converts the data into a string object! which I don't want.
>
>
> Expected result: I am willing to have a result as a decimal number in a float64 format.

Float64 is a binary number format, not a decimal format. What you ask 
can't be done.

As to what you want:

For most purposes, you can think of the float64 object storing the 
Platonic ideal of the number, not any particular representation of it. 
0.00005 and 5E-5 are the same number. End of story.

If you want to work with the number, you don't care what it looks like. 
If you want to display the number, you do care what it looks like, and 
you want a str rather than a float.


>
> System: (Python 3.7.4 running on Win10)
>
>
> Regards,





More information about the Python-list mailing list