Python - How To Max Float Value in Python

ID : 489

viewed : 107

Tags : PythonPython Float

vote vote

94

This tutorial will demonstrate this method to determine the max float value you can store in Python.

Max float Value With the sys.float_info in Python

In Python, we can use the sys.maxint function inside the built-in sys module to find out the maximum value that can be stored in an integer variable. We can also use the same sys module to find out the maximum value that can be stored inside a float variable with the sys.float_info. The is a tuple that holds useful information about the float data type in Python.

The sys.float_info.max gives us the largest value that can be stored inside a float variable. The following program snippet shows us how to use the sys module to find the maximum value that can be stored inside a float variable.

import sys sys.float_info.max 

Output:

1.7976931348623157e+308 

We found out the maximum value that a float variable can hold with the sys.float_info.max in the code above. The output shows that the upper limit of a float variable is 1.7976931348623157e+308.

  • Related HOW TO?