Python's built-in float type has double precision (it's a C double in CPython, a Java double in Jython). If you need more precision, get NumPy and use its numpy.float128.
Top answer 1 of 5
196
Python's built-in float type has double precision (it's a C double in CPython, a Java double in Jython). If you need more precision, get NumPy and use its numpy.float128.
2 of 5
74
Decimal datatype
- Unlike hardware based binary floating point, the decimal module has a user alterable precision (defaulting to 28 places) which can be as large as needed for a given problem.
If you are pressed by performance issuses, have a look at GMPY
Floating-point numbers
The result of 12+12.23 is 35.120000000000005 The result of 23+12.23 is 35.230000000000004 And the result of 1.2-1 is 0.19999999999999996 But in C++ the results are true. Why?What is the difference between C++ and Python at floating-point numbers Note: The result of 0.1+0.1 is 0.2 It is true.But ... More on discuss.python.org
types - Python: Float or Double - Stack Overflow
I need to pack numbers in Python using the struct module. I want to check if a number is float or double, when I pack it. How can I do that? Is there any built-in functions, or I need to write one?... More on stackoverflow.com
Difference between Float and Double Data types? - Python - Digi Technical Support Forums
Apart from memory size of Float and Double data types, I want to know any other differences and also want to know when we use float and when we use double Data type? More on forums.digi.com
[deleted by user]
Assuming you mean the c/c++ double type...? Any floating point number in python is stored as double. So 1.1 5.7 and -1453.653356 https://www.pythontutorial.net/advanced-python/python-float/ If not, please provide an example of the data type you mean. More on reddit.com
Videos
Floats and Integers | How To Python - YouTube
03:14
define double in python - YouTube
Python Integers vs Floats - Visually Explained
11:43
Python Programming for Beginners: Lesson 6 - Float Type - YouTube
07:43
Lesson 4- Basic Data Types in Python (int, float, str, bool) - YouTube
03:00
float() built-in function in Python - YouTube
Reddit
reddit.com › r/learnprogramming › float vs. double – what's the key difference?"
r/learnprogramming on Reddit: float vs. double – What's the Key Difference?"
November 2, 2024 -
New to programming and curious: what's the main difference between float and double? When should I use one over the other?
Thanks! 🙏😊
Top answer 1 of 5
19
It can depend on the language spec, but usually the amount of memory and therefore the precision allowed by the type. Usually: A double will use 8 bytes or 64 bits of memory while a float uses only 4 bytes or 32 bits. This means that a float is less precise since it can store fewer digits after the decimal place. The way it works is that some bits of the datatype are used for the whole number portion of the number and some for the decimal portion. So as you can see, double, using more memory can have more bits allocated to the decimal portion making it more precise. See balefrost's reply to my comment for a correct explanation of this. Using float means using less memory, having more efficient code (due to lower precision so saving on calculations) and handling a smaller range of numbers (floats handle a smaller range than double due to reduced memory usage). Hope this helps!
2 of 5
3
The difference is memory size. Floats in Java (which I assume is the language you’re talking about) take up 32 bits of memory, the same as an integer. Doubles, as you might guess from the name, take up double the space: 64 bits. Doubles use those extra bits to both store a wider range of numbers and add more precision to the numbers they can store as well. There’s really seldom any reason to use floats in modern Java applications since memory is no longer a limiting factor for most programs. However, back in the day memory used to be much more limited so you would stick to regular floats as long as they were good enough for what you’re doing and only use doubles when absolutely necessary. This was starting to change even as Java was first created, but a lot of things in Java were designed to make the transition easier for programmers who were used to using C, a popular language at the time.
Top answer 1 of 4
1
Note in both languages the actual numerical result should be exactly the same - Python floats are going to be identical to C doubles. The difference is how the language is choosing to convert them to strings to display them. Notice how if you rounded Python’s result to say 10 decimal places, it’d be…
2 of 4
0
Some language runtimes round floats and doubles.
Decimal numbers sometimes do not have a precise representation in binary math - and floats and doubles are binary math.
If you need precisely-represented decimal values (EG, for an accounting application), use decimal math like the decimal.Decimal c…
AskPython
askpython.com › home › double precision floating values in python
Double precision floating values in Python - AskPython
April 10, 2025 - Python’s standard float type, based on double-precision IEEE 754 format, provides up to 15 decimal digits of precision. For tasks needing more precision, Python offers decimal. Decimal with configurable precision, fractions.Fraction for exact irreducible fractions, and numpy.float128 for up to 113 bits of precision.
Google Groups
groups.google.com › g › cython-users › c › XEgZMHvYv8Q
float v. double
Judging from https://docs.python.org/2/c-api/float.html > there would indeed be very little advantage to statically type a PyFloat. Cython automatically coerces C floating point values back to Python "float" objects at need, and Python's "float" otherwise behaves exactly like C's "double", so there is really no advantage in typing anything as "Python float".
Squash
squash.io › how-to-use-double-precision-floating-values-in-python
How to Use Double Precision Floating Values in Python
November 2, 2023 - In the above examples, the arithmetic operations are performed on double precision floating values, and the results are also double precision floating values. Python provides several ways to format double precision floating values for display. One common method is to use the format function or the f-string syntax introduced in Python 3.6.
Reddit
reddit.com › r/learnpython › [deleted by user]
What is a double? (Data type) : r/learnpython
May 2, 2022 - from google: Python does not have an inbuilt double data type, but it has a float type that designates a floating-point number. You can count double in Python as float values which are specified with a decimal point. All platforms represent Python float values as 64-bit “double-precision” ...
GeeksforGeeks
geeksforgeeks.org › python-float-type-and-its-methods
Float type and its methods in python - GeeksforGeeks
February 21, 2025 - a = 10.5 # Float declaration b = -3.14 # Negative float c = 2.0 # Even if it looks like an integer, it's a float d = 1.23e4 # Scientific notation (1.23 × 10⁴ = 12300.0) e = 5e-3 # Scientific notation (5 × 10⁻³ = 0.005) print(a,b,c,d,e) Python provides several built-in methods for float objects.