>>> numpy.float64(5.9975).hex()
'0x1.7fd70a3d70a3dp+2'
>>> (5.9975).hex()
'0x1.7fd70a3d70a3dp+2'

They are the same number. What differs is the textual representation obtained via by their __repr__ method; the native Python type outputs the minimal digits needed to uniquely distinguish values, while NumPy code before version 1.14.0, released in 2018 didn't try to minimise the number of digits output.

Answer from Ignacio Vazquez-Abrams on Stack Overflow
Top answer
1 of 2
70
>>> numpy.float64(5.9975).hex()
'0x1.7fd70a3d70a3dp+2'
>>> (5.9975).hex()
'0x1.7fd70a3d70a3dp+2'

They are the same number. What differs is the textual representation obtained via by their __repr__ method; the native Python type outputs the minimal digits needed to uniquely distinguish values, while NumPy code before version 1.14.0, released in 2018 didn't try to minimise the number of digits output.

2 of 2
3

Numpy float64 dtype inherits from Python float, which implements C double internally. You can verify that as follows:

isinstance(np.float64(5.9975), float)   # True

So even if their string representation is different, the values they store are the same.

On the other hand, np.float32 implements C float (which has no analog in pure Python) and no numpy int dtype (np.int32, np.int64 etc.) inherits from Python int because in Python 3 int is unbounded:

isinstance(np.float32(5.9975), float)   # False
isinstance(np.int32(1), int)            # False

So why define np.float64 at all?

np.float64 defines most of the attributes and methods in np.ndarray. From the following code, you can see that np.float64 implements all but 4 methods of np.array:

[m for m in set(dir(np.array([]))) - set(dir(np.float64())) if not m.startswith("_")]

# ['argpartition', 'ctypes', 'partition', 'dot']

So if you have a function that expects to use ndarray methods, you can pass np.float64 to it while float doesn't give you the same.

For example:

def my_cool_function(x):
    return x.sum()

my_cool_function(np.array([1.5, 2]))   # <--- OK
my_cool_function(np.float64(5.9975))   # <--- OK
my_cool_function(5.9975)               # <--- AttributeError
🌐
NumPy
numpy.org › doc › stable › user › basics.types.html
Data types — NumPy v2.5 Manual
Note that, above, we could have used the Python float object as a dtype instead of numpy.float64. NumPy knows that int refers to numpy.int_, bool means numpy.bool, that float is numpy.float64 and complex is numpy.complex128.
Discussions

which data type should I use for most accurate calculations? float decimal or python?
Floats are great but unreliable - they have small imprecisions that can quickly add up. More on reddit.com
🌐 r/learnpython
7
1
March 25, 2023
Should I use numpy.float64 instead of Python float when also using numpy.array - Stack Overflow
I have not encountered any problems thus far, so this is a question purely out of curiosity. In Python I usually define floats and arrays of floats like this: import numpy as np s = 1.0 v = np.a... More on stackoverflow.com
🌐 stackoverflow.com
Performance Issue using float vs. np.float64 - NGSolve - Netgen/NGSolve
Hello everybody, I just came across some unexpected performance behavior of NGSolve that might be interesting. When building a matrix from two existing matrices, it makes a huge difference if one multiplies with a Pytho… More on forum.ngsolve.org
🌐 forum.ngsolve.org
0
February 4, 2025
python - Is it necessary to use "numpy.float64"? - Stack Overflow
i recently saw an example about "Linear regression" where he uses while creating an array with numpy in order with dtype = numpy.float64 More on stackoverflow.com
🌐 stackoverflow.com
December 1, 2018
🌐
Medium
medium.com › @amit25173 › understanding-numpy-float64-a300ac9e096a
Understanding numpy.float64. If you think you need to spend $2,000… | by Amit Yadav | Medium
February 8, 2025 - The main difference lies in precision. float64 uses 64 bits, offering more precision (about 15–17 decimal places) than float32, which uses only 32 bits and is limited to around 7 decimal places.
🌐
CSDN
devpress.csdn.net › python › 63045fb87e6682346619ab50.html
Difference between numpy.float and numpy.float64_python_Mangs-Python
August 23, 2022 - np.float is an alias for python float type. np.float32 and np.float64 are numpy specific 32 and 64-bit float types.
🌐
Quora
quora.com › What-is-np-float32-and-np-float64-in-numpy-in-simple-terms
What is np.float32 and np.float64 in numpy in simple terms? - Quora
Answer (1 of 2): np.float32 - It means that each value in the numpy array would be a float of size 32 bits. np.float64- It means that each value in the numpy array would be a float of size 64. If you are concerned about storing big numbers you should consider using float64, however, it takes mo...
🌐
pythontutorials
pythontutorials.net › blog › difference-between-numpy-float-and-numpy-float64
Numpy.float vs Numpy.float64: Understanding the Subtle Difference Explained — pythontutorials.net
Alias Nature: numpy.float is not a distinct dtype but a shorthand for a default floating-point type. Historically, this default was platform-dependent: on 32-bit systems, it might have aliased float32, but today, 64-bit systems dominate, making ...
🌐
YouTube
youtube.com › watch
NumPy Float Data Types: float16 vs float32 vs float64 Explained with Examples - YouTube
🔢 Master NumPy float data types in this comprehensive tutorial! Learn the critical differences between float16, float32, and float64, and discover how to ch...
Published: October 28, 2025
Find elsewhere
🌐
NumPy
numpy.org › doc › 1.22 › user › basics.types.html
Data types — NumPy v1.22 Manual
Python’s floating-point numbers are usually 64-bit floating-point numbers, nearly equivalent to np.float64. In some unusual situations it may be useful to use floating-point numbers with more precision.
🌐
NumPy
numpy.org › doc › 2.1 › user › basics.types.html
Data types — NumPy v2.1 Manual
Note that, above, we could have used the Python float object as a dtype instead of numpy.float64. NumPy knows that int refers to numpy.int_, bool means numpy.bool, that float is numpy.float64 and complex is numpy.complex128.
🌐
NumPy
numpy.org › devdocs › user › basics.types.html
Data types — NumPy v2.6.dev0 Manual
Note that, above, we could have used the Python float object as a dtype instead of numpy.float64. NumPy knows that int refers to numpy.int_, bool means numpy.bool, that float is numpy.float64 and complex is numpy.complex128.
🌐
Python⇒Speed
pythonspeed.com › articles › float64-float32-precision
The problem with float32: you only get 16 million values
February 1, 2023 - Libraries like NumPy and Pandas let you switch data types, which allows you to reduce memory usage. Switching from numpy.float64 (“double-precision” or 64-bit floats) to numpy.float32 (“single-precision” or 32-bit floats) cuts memory ...
🌐
Netgen/NGSolve
forum.ngsolve.org › t › performance-issue-using-float-vs-np-float64 › 3240
Performance Issue using float vs. np.float64 - NGSolve - Netgen/NGSolve
February 4, 2025 - Hello everybody, I just came across some unexpected performance behavior of NGSolve that might be interesting. When building a matrix from two existing matrices, it makes a huge difference if one multiplies with a Python float or a numpy.float64. I created a minimal working example (MWE) to test on your machine.
🌐
Codegive
codegive.com › blog › numpy_float64_vs_float.php
NumPy float64 vs. Python float
Python List of floats: Each float is a separate Python object with its own overhead, plus the overhead of the list itself which stores references to these objects. This leads to substantial memory consumption. NumPy Array of float64s: The array stores the raw 8-byte values contiguously in memory, with minimal overhead for the array object itself.
🌐
GitHub
github.com › numpy › numpy › issues › 21906
`np.float64` is not accepted as `float` under static type checks · Issue #21906 · numpy/numpy
July 2, 2022 - # Python version 3.8.10, numpy version 1.23.0 import numpy as np x = np.float64(1.0) print(f"x={x} of type={type(x)} is float: {isinstance(x, float)}") # x=1.0 of type=<class 'numpy.float64'> is float: True def f(a: float) -> float: return a f(x) """ pyright 1.1.256: error: Argument of type "float64" cannot be assigned to parameter "a" of type "float" in function "f" "float64" is incompatible with "float" (reportGeneralTypeIssues) mypy 0.961: error: Argument 1 to "f" has incompatible type "floating[_64Bit]"; expected "float" """
Author: numpy
🌐
GitHub
github.com › scikit-learn › scikit-learn › discussions › 20490
Return Python `float` instead of `numpy.float64` in metrics · scikit-learn/scikit-learn · Discussion #20490
In the 🤗 datasets library we rely on various sklearn.metrics to compute things like accuracy, F1-score etc. One issue we've run into is that the return type from functions like sklearn.metrics.accuracy is numpy.float64 which doesn't play nice with yaml.dump, e.g.