The IEEE 754-2008 16-bit base 2 format, aka binary16, doesn't give you a lot of precision. What do you expect from 16 bits? :) 1 bit is the sign bit, 5 bits are used for the exponent, and that leaves 10 bits to store the normalised 11 bit mantissa, so anything > 2**11 == 2048 has to be quantized.

According to Wikipedia, integers between 4097 and 8192 round to a multiple of 4, and integers between 8193 and 16384 round to a multiple of 8.

Answer from PM 2Ring on Stack Overflow
🌐
GitHub
github.com › numpy › numpy › issues › 8063
float16 precision · Issue #8063 · numpy/numpy
September 19, 2016 - [ 0.0429911] float64 [ 0.0429911] float32 Convert: [ 0.04299927] float16 [ 0.04299927] float32 Round and Convert: [ 0.042991] float32 [ 0.04299927] float16 [ 0.04299927] float32 · float16 always drop more precision than rounding the number, given the fact that it can preserve precision upto 4 number in the fraction · from __future__ import print_function, division, absolute_import import numpy as np np.random.seed(1208) X = np.random.rand(12, 12) X16 = X.astype('float16').astype('float32') XR = np.around(X, decimals=4) print('Float16:', np.sum(np.abs(X - X16))) print('Round:', np.sum(np.abs(X - XR)))
Author   trungnt13
🌐
NumPy
numpy.org › doc › stable › user › basics.types.html
Data types — NumPy v2.4 Manual
NumPy numerical types are instances of numpy.dtype (data-type) objects, each having unique characteristics. Once you have imported NumPy using import numpy as np you can create arrays with a specified dtype using the scalar types in the numpy top-level API, e.g. numpy.bool, numpy.float32, etc.
🌐
NumPy
numpy.org › doc › 1.16 › user › basics.types.html
Data types — NumPy v1.16 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.
🌐
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")
🌐
GitHub
github.com › numpy › numpy › issues › 12721
np.array(..., dtype=np.float32).astype(np.float16) doesn't handle denorms properly · Issue #12721 · numpy/numpy
January 11, 2019 - However, any value that is slightly above 2**-25 should be rounded up to 2**-24. The following interpreter sequence shows such a case that is properly handled by the float64->float16 conversion, but not by the float32->float16 conversion (see the last line below). $ python3 Python 3.5.2 (default, Nov 12 2018, 13:43:14) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import numpy as np >>> np.__version__ '1.14.3' >>> '%.40f' % np.array([2**-24]).astype(np.float64)[0] '0.0000000596046447753906250000000000000000' >>> '%.40f' % np.array([2**
Author   DickJC123
🌐
GeeksforGeeks
geeksforgeeks.org › python › using-numpy-to-convert-array-elements-to-float-type
Using NumPy to Convert Array Elements to Float Type - GeeksforGeeks
July 15, 2025 - This approach reuses the astype() method like before, but here you overwrite the original array with the converted one. It’s a form of in-place reassignment, not true in-place conversion which NumPy doesn’t support due to fixed data types .
Find elsewhere
🌐
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.
🌐
NumPy
numpy.org › doc › 2.1 › user › basics.types.html
Data types — NumPy v2.1 Manual
>>> np.array([1, 2, 3], dtype='f') ... type objects, including how to specify parameters like the byte order. To convert the type of an array, use the .astype() method....
🌐
w3resource
w3resource.com › numpy › data-types.php
NumPy: Data types - w3resource
>>> import numpy as np >>> np.array([3, 5, 7], dtype='f') array([3., 5., 7.], dtype=float32) To convert the type of an array, use the .astype() method (preferred) or the type itself as a function.
🌐
Google Groups
groups.google.com › g › uavcan › c › V1S8lttpc9Q
Converter float16 back to float32
Hi, I try to create my base station wherr are two 7 zoll tft's build in. I will have a look on temperature, current and voltages from my vehikel. Now i have a Problem to convert the float16 back to float32. Have someone a ready to use function?
🌐
NumPy
numpy.org › devdocs › user › basics.types.html
Data types — NumPy v2.5.dev0 Manual
NumPy numerical types are instances of numpy.dtype (data-type) objects, each having unique characteristics. Once you have imported NumPy using import numpy as np you can create arrays with a specified dtype using the scalar types in the numpy top-level API, e.g. numpy.bool, numpy.float32, etc.
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.ndarray.astype.html
numpy.ndarray.astype — NumPy v2.1 Manual
‘same_kind’ means only safe casts or casts within a kind, like float64 to float32, are allowed.
🌐
Google Groups
groups.google.com › g › cython-users › c › yubkr1nySA8
Question about numpy.float16 support in cython
July 24, 2021 - The trouble is that most modern CPUs don't have a float16 data type so if you managed to get access to it in C (or Cython) then the compiler wouldn't know what to do with it. It looks like https://github.com/numpy/numpy/blob/623bc1fae1d47df24e7f1e29321d0c0ba2771ce0/numpy/core/include/numpy/halffloat.h defines a few operations on the type, and for everything else you convert it to/from float32 when you need to use it.
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.ndarray.astype.html
numpy.ndarray.astype — NumPy v2.4 Manual
June 22, 2021 - ‘same_kind’ means only safe casts or casts within a kind, like float64 to float32, are allowed.
🌐
w3resource
w3resource.com › python-exercises › numpy › basic › numpy-basic-exercise-41.php
NumPy: Convert numpy dtypes to native python types - w3resource
August 28, 2025 - # Importing the NumPy library with an alias 'np' import numpy as np # Printing a message indicating conversion from numpy.float32 to Python float print("numpy.float32 to python float") # Creating a numpy.float32 value 'x' initialized to 0 x = np.float32(0) # Printing the type of 'x' print(type(x)) # Extracting the Python float value from the numpy.float32 'x' using the item() method pyval = x.item() # Printing the type of the extracted Python float value 'pyval' print(type(pyval))
🌐
Note.nkmk.me
note.nkmk.me › home › python › numpy
NumPy: astype() to change dtype of an array | note.nkmk.me
February 4, 2024 - Even in operations between integers or floating-point numbers, if their bit sizes differ, the result is converted to the type with the larger bit size. a_int16 = np.array([1, 2, 3], np.int16) a_int32 = np.array([1, 2, 3], np.int32) print((a_int16 + a_int32).dtype) # int32 a_float16 = np.array([1, 2, 3], np.float16) a_float32 = np.array([1, 2, 3], np.float32) print((a_float16 + a_float32).dtype) # float32