Double values in python

10,567

Solution 1

According to the documentation:

Floating point numbers are usually implemented using double in C; information about the precision and internal representation of floating point numbers for the machine on which your program is running is available in sys.float_info.

Solution 2

If you are going to perform mathematical operations on this data and accuracy is an issue I suggest you'll look at the decimal data type we had some issues with floating point error.

Decimal “is based on a floating-point model which was designed with people in mind, and necessarily has a paramount guiding principle – computers must provide an arithmetic that works in the same way as the arithmetic that people learn at school.”

Share:
10,567
Indian
Author by

Indian

Mon dieu, je suis sur Stackoverflow! Quelle charmante surprise!

Updated on August 21, 2022

Comments

  • Indian
    Indian over 1 year

    I have values like 656364.53 which has to be read from a text file. From my programming experience, I have learnt that is value takes the double data type, to be retained as a proper value.

    In python however, it seems that there is only float or the single - precision value. Therefore as per my experience, these values get changed on reading.

    How do I get double precision values in python.