a = np.array([0.123456789121212,2,3], dtype=np.float16)
print("16bit: ", a[0])

a = np.array([0.123456789121212,2,3], dtype=np.float32)
print("32bit: ", a[0])

b = np.array([0.123456789121212121212,2,3], dtype=np.float64)
print("64bit: ", b[0])
  • 16bit: 0.1235
  • 32bit: 0.12345679
  • 64bit: 0.12345678912121212
Answer from Furkan Gulsen on Stack Overflow
🌐
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 usage in half. But it does so at a cost: float32 can only store a much smaller range of numbers, with less precision.
🌐
Note.nkmk.me
note.nkmk.me › home › python
Maximum and Minimum float Values in Python | note.nkmk.me
August 11, 2023 - In Python, the float type is a 64-bit double-precision floating-point number, equivalent to double in languages like C. This article explains how to get and check the range (maximum and minimum values ...
Discussions

python - The real difference between float32 and float64 - Stack Overflow
I want to understand the actual difference between float16 and float32 in terms of the result precision. For instance, NumPy allows you to choose the range of the datatype you want (np.float16, np. More on stackoverflow.com
🌐 stackoverflow.com
If float32 is only 6-7 digits, how do values where the first 6-7 digits are just 0s make sense?
Floating point can stores certain number of digits at any location in the number due to being able to "float" the decimal point. It's always storing something like 0.3456789 and how many places should the point move in what direction. So you can tell it to move 10 places to the left, and you'll get: 0.0000000003456789 More on reddit.com
🌐 r/learnpython
9
1
September 6, 2022
floating point - What is the range of values a float can have in Python? - Stack Overflow
What are its smallest and biggest values in python? More on stackoverflow.com
🌐 stackoverflow.com
python - range() for floats - Stack Overflow
This is quite a twisted argument. range() should simply be looked at iteration generator and whether it is used in for loop or to index something should be left to callers. People have been using floats in for loop for millenia and above justifications are nonsensical. People in Python committees ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
PYnative
pynative.com › home › python › python range of float numbers
Python range of float numbers
April 13, 2021 - For example, np.arange(0.5, 6.5, 1.5) will return the sequence of floating-point numbers starting from 0.5 up to 6.5. ... import numpy as np # range for floats with np.arange() for i in np.arange(0, 4.5, 0.5): print(i, end=', ') # Output 0.0, ...
🌐
University of Texas
cs.utexas.edu › ~mitra › csSpring2017 › cs303 › lectures › math.html
Doing Math in Python
32-bit floating point numbers have lower precision than 64-bit numbers. There is also a limit to how big or how small a floating point number you can represent. For a 32-bit representation the range is (+/-) 3.4E38 and for 64-bit representation the range is (+/-) 1.8E308.
Find elsewhere
🌐
Wikipedia
en.wikipedia.org › wiki › Single-precision_floating-point_format
Single-precision floating-point format - Wikipedia
3 weeks ago - Single precision is termed REAL(4) or REAL*4 in Fortran; SINGLE-FLOAT in Common Lisp; float binary(p) with p≤21, float decimal(p) with the maximum value of p depending on whether the DFP (IEEE 754 DFP) attribute applies, in PL/I; float in C with IEEE 754 support, C++ (if it is in C), C# and Java; Float in Haskell and Swift; and Single in Object Pascal (Delphi), Visual Basic, and MATLAB. However, float in Python, Ruby, PHP, and OCaml and single in versions of Octave before 3.2 refer to double-precision numbers.
🌐
Pythoninformer
pythoninformer.com › python-libraries › numpy › data-types
PythonInformer - Data types
September 14, 2019 - float64 numbers store floating point numbers in the same way as a Python float value. They are sometimes called double precision. float32 numbers take half as much storage as float64, but they have considerably smaller range and .
🌐
TechBeamers
techbeamers.com › python-float-range
Generate Floating Point Range in Python - TechBeamers
November 30, 2025 - Do you wish to learn how to generate a float range of numbers in Python? In this tutorial, you will find many ways to produce floating point values within a given range. We’ve provided several Python…
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › python range() with float values
Python range() with float values - Spark By {Examples}
May 31, 2024 - The range() function in python is used to generate values within the specified range of integers but not float. It will take only integer values.
🌐
GitHub
github.com › numpy › numpy › issues › 12149
python 2.7 range accepts numpy float16, float32, complex when it should raise TypeError · Issue #12149 · numpy/numpy
October 11, 2018 - >>> import numpy as np >>> range(np.float16(4)) [0, 1, 2, 3] >>> range(np.float32(4)) [0, 1, 2, 3] >>> range(np.complex64(4.)) /home/mark/miniconda3/envs/np2/bin/ipython:1: ComplexWarning: Casting complex values to real discards the imaginary part #!/home/mark/miniconda3/envs/np2/bin/python [0, 1, 2, 3] >>> range(np.complex128(4.)) /home/mark/miniconda3/envs/np2/bin/ipython:1: ComplexWarning: Casting complex values to real discards the imaginary part #!/home/mark/miniconda3/envs/np2/bin/python [0, 1, 2, 3] >>> range(np.float128(1)) [0]
Author   hmaarrfk
🌐
Simplilearn
simplilearn.com › home › resources › software development › python float() function: key concepts [with examples]
Python float() Function: Key Concepts [With Examples]
November 27, 2024 - Learn how the float() function in Python converts a specified value into a floating point number. Syntax: float(value). A key function for numeric conversions.
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
🌐
Python Data Science Handbook
jakevdp.github.io › PythonDataScienceHandbook › 02.01-understanding-data-types.html
Understanding Data Types in Python | Python Data Science Handbook
array([ 1., 2., 3., 4.], dtype=float32) Finally, unlike Python lists, NumPy arrays can explicitly be multi-dimensional; here's one way of initializing a multidimensional array using a list of lists: In [11]: # nested lists result in multi-dimensional arrays np.array([range(i, i + 3) for i in [2, 4, 6]]) Out[11]: array([[2, 3, 4], [4, 5, 6], [6, 7, 8]]) The inner lists are treated as rows of the resulting two-dimensional array.
🌐
Python documentation
docs.python.org › 3 › tutorial › floatingpoint.html
15. Floating-Point Arithmetic: Issues and Limitations — Python 3.14.3 documentation
Floating-point numbers are represented in computer hardware as base 2 (binary) fractions. For example, the decimal fraction 0.625 has value 6/10 + 2/100 + 5/1000, and in the same way the binary fra...
🌐
Reddit
reddit.com › r/learnpython › how do i get max value of np.float32?
How do I get max value of np.float32? : r/learnpython
March 31, 2021 - Subreddit for posting questions and asking for general advice about all topics related to learning python. ... Sorry, this post was deleted by the person who originally posted it. Share ... The maximum value of a float32 is infinity.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-range-for-float-numbers
Python - range() for Float Numbers - GeeksforGeeks
July 23, 2025 - We created a function float_range() that yields values from start to stop with a step size of 0.5.
🌐
Javatpoint
javatpoint.com › range-of-float-in-python
Range of float in python - Javatpoint
Range of float in python with tutorial, tkinter, button, overview, canvas, frame, environment set-up, first python program, etc.