Python's standard float type is a C double: http://docs.python.org/2/library/stdtypes.html#typesnumeric

NumPy's standard numpy.float is the same, and is also the same as numpy.float64.

Answer from John Zwinck on Stack Overflow
🌐
NumPy
numpy.org › doc › stable › user › basics.types.html
Data types — NumPy v2.5 Manual
These scalar types as arguments to the dtype keyword that many numpy functions or methods accept. For example: >>> z = np.arange(3, dtype=np.uint8) >>> z array([0, 1, 2], dtype=uint8) Array types can also be referred to by character codes, for example: >>> np.array([1, 2, 3], dtype='f') array([1., 2., 3.], dtype=float32) >>> np.array([1, 2, 3], dtype='d') array([1., 2., 3.], dtype=float64)
🌐
NumPy
numpy.org › doc › 1.22 › user › basics.types.html
Data types — NumPy v1.22 Manual
>>> np.array([1, 2, 3], dtype='f') array([ 1., 2., 3.], dtype=float32) We recommend using dtype objects instead. To convert the type of an array, use the .astype() method (preferred) or the type itself as a function. For example: >>> z.astype(float) array([ 0., 1., 2.]) >>> np.int8(z) array([0, 1, 2], dtype=int8) Note that, above, we use the Python float object as a dtype. NumPy knows that int refers to np.int_, bool means np.bool_, that float is np.float_ and complex is np.complex_.
🌐
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 ... or 64-bit floats) to numpy.float32 (“single-precision” or 32-bit floats) cuts memory usage in half....
🌐
NumPy
numpy.org › doc › 2.1 › reference › arrays.scalars.html
Scalars — NumPy v2.1 Manual
numpy.float32: 32-bit-precision floating-point number type: sign bit, 8 bits exponent, 23 bits mantissa.
🌐
NumPy
numpy.org › doc › 2.3 › reference › arrays.scalars.html
Scalars — NumPy v2.3 Manual
numpy.float32: 32-bit-precision floating-point number type: sign bit, 8 bits exponent, 23 bits mantissa.
Top answer
1 of 2
63

Python's standard float type is a C double: http://docs.python.org/2/library/stdtypes.html#typesnumeric

NumPy's standard numpy.float is the same, and is also the same as numpy.float64.

2 of 2
3

Data type-wise numpy floats and built-in Python floats are the same, however boolean operations on numpy floats return np.bool_ objects, which always return False for val is True. Example below:

In [1]: import numpy as np
   ...: an_np_float = np.float32(0.3)
   ...: a_normal_float = 0.3
   ...: print(a_normal_float, an_np_float)
   ...: print(type(a_normal_float), type(an_np_float))

0.3 0.3
<class 'float'> <class 'numpy.float32'>

Numpy floats can arise from scalar output of array operations. If you weren't checking the data type, it is easy to confuse numpy floats for native floats.

In [2]: criterion_fn = lambda x: x <= 0.5
   ...: criterion_fn(a_normal_float), criterion_fn(an_np_float)

Out[2]: (True, True)

Even boolean operations look correct. However the result of the numpy float isn't a native boolean datatype, and thus can't be truthy.


In [3]: criterion_fn(a_normal_float) is True, criterion_fn(an_np_float) is True
Out[3]: (True, False)

In [4]: type(criterion_fn(a_normal_float)), type(criterion_fn(an_np_float))
Out[4]: (bool, numpy.bool_)

According to this github thread, criterion_fn(an_np_float) == True will evaluate properly, but that goes against the PEP8 style guide.

Instead, extract the native float from the result of numpy operations. You can do an_np_float.item() to do it explicitly (ref: this SO post) or simply pass values through float().

🌐
JAX Documentation
docs.jax.dev › en › latest › _autosummary › jax.numpy.float32.html
jax.numpy.float32 — JAX documentation
A JAX scalar constructor of type float32. While NumPy defines scalar types for each data type, JAX represents scalars as zero-dimensional arrays.
🌐
NumPy
numpy.org › doc › stable › reference › arrays.scalars.html
Scalars — NumPy v2.5 Manual
numpy.float32: 32-bit-precision floating-point number type: sign bit, 8 bits exponent, 23 bits mantissa.
Find elsewhere
🌐
GitHub
github.com › numpy › numpy › issues › 14150
How to convert np.float32 to Python float easily? · Issue #14150 · numpy/numpy
July 29, 2019 - Hi, I try to convert np.float32 to a Python float in my project, and I find it's not eaisly. I have to convert it to str and then convert to float. ... import numpy as np x = np.float32(1.9) x.tolist() # 1.899999976158142 x.item() # 1.899999976158142 x.view() # 1.9 str(x) # '1.9' float(str(x)) # 1.9
Author   numpy
🌐
IncludeHelp
includehelp.com › python › how-to-convert-numpy-array-type-and-values-from-float64-to-float32.aspx
Python - How to convert NumPy array type and values from Float64 to Float32?
# Import numpy import numpy as np # Creating a numpy array arr = np.ones(4,dtype="float64") # Display original array print("Original Array:\n",arr,"\n") # Display type of original array print("type of Original Array:\n",arr.dtype,"\n") # Converting array into float32 arr = np.float32(arr) # Display type of modified array print("type of modified array:\n",arr.dtype,"\n")
🌐
TutorialsPoint
tutorialspoint.com › numpy › numpy_data_types.htm
NumPy - Data Types
Original array: [1 2 3 4 5] Original dtype: int64 Converted array: [1. 2. 3. 4. 5.] Converted dtype: float32 · NumPy also provides functions for casting arrays to specific types.
🌐
w3resource
w3resource.com › python-exercises › numpy › basic › numpy-basic-exercise-41.php
NumPy: Convert numpy dtypes to native python types - w3resource
August 28, 2025 - np.float32(0) creates a NumPy scalar of data type float32 stores in the variable 'x' and initializes it with the value 0.
🌐
NumPy
numpy.org › doc › 2.2 › reference › arrays.scalars.html
Scalars — NumPy v2.2 Manual
numpy.float32: 32-bit-precision floating-point number type: sign bit, 8 bits exponent, 23 bits mantissa.
🌐
NumPy
numpy.org › devdocs › reference › arrays.scalars.html
Scalars — NumPy v2.6.dev0 Manual
numpy.float32: 32-bit-precision floating-point number type: sign bit, 8 bits exponent, 23 bits mantissa.
🌐
Sling Academy
slingacademy.com › article › explaining-numpy-float32-type-4-examples
Explaining numpy.float32 type (4 examples) - Sling Academy
Before we embark on the practical examples, it’s crucial to understand what numpy.float32 is and why it is significant. In essence, numpy.float32 is a dtype that represents a 32-bit single precision floating point number as specified by the IEEE 754 standard.
🌐
GitHub
github.com › numpy › numpy › issues › 6860
How to set float32 as default · Issue #6860 · numpy/numpy
December 19, 2015 - I use cuBLAS + numpy, cuBLAS run very fast on float32, 10times faster than CPU. However, I need to set dtype=float32 everytime by hand, it's tedious. random.rand() even doesn't support to create float32 array. Is there anyway to set the ...
Author   numpy
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.finfo.html
numpy.finfo — NumPy v2.1 Manual
>>> import numpy as np >>> np.finfo(np.float64).dtype dtype('float64') >>> np.finfo(np.complex64).dtype dtype('float32') Attributes: bitsint · The number of bits occupied by the type. dtypedtype · Returns the dtype for which finfo returns information. For complex input, the returned dtype is the associated float* dtype for its real and complex components.