What is the maximum value of float in Python?

In Python, floating-point numbers are implemented using double-precision, i.e., 64-bit format, as per the IEEE 754 standard. These floats have a finite range and precision.

The maximum value that a float can represent depends on the platform, but can be accessed using the sys.float_info attribute.

Maximum Value of Float using sys.float_info

The sys.float_info object provides details about the float implementation on the current platform. The attribute float_info.max gives the largest positive floating-point number representation.

Example

Here we use float_info.max attribute from the sys.float_info object to get the maximum float value in Python ?

import sys

# Get the maximum float value
print("Maximum float value:", sys.float_info.max)

The output of the above code is ?

Maximum float value: 1.7976931348623157e+308

Other Float Information Attributes

The sys.float_info object provides various constants related to the float type. Some commonly used attributes are ?

  • max: Maximum representable positive finite float
  • min: Minimum positive normalized float
  • epsilon: Difference between 1 and the smallest representable float greater than 1

Example

Here we use multiple float attributes to display their respective values ?

import sys

print("Maximum float value:", sys.float_info.max)
print("Minimum positive normalized float:", sys.float_info.min)
print("Float epsilon:", sys.float_info.epsilon)

The output of the above code is ?

Maximum float value: 1.7976931348623157e+308
Minimum positive normalized float: 2.2250738585072014e-308
Float epsilon: 2.220446049250313e-16

Understanding the Scientific Notation

The maximum float value 1.7976931348623157e+308 uses scientific notation. This represents approximately 1.798 × 10308, an extremely large number with 308 digits.

Example

Let's see what happens when we exceed this maximum value ?

import sys

max_float = sys.float_info.max
print("Maximum float:", max_float)

# Attempting to exceed the maximum
try:
    overflow = max_float * 10
    print("Overflow result:", overflow)
except OverflowError:
    print("OverflowError occurred!")

The output of the above code is ?

Maximum float: 1.7976931348623157e+308
Overflow result: inf

Conclusion

Python's maximum float value is approximately 1.798 × 10308, accessible via sys.float_info.max. Exceeding this limit results in infinity (inf) rather than an error.

Updated on: 2026-03-24T18:39:43+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements