Float class
Float class is used to represent the floating-point numbers. Syntax of this Float class is given below
from sympy import Float Float(any_Number)
Here any_Number is the floating-point number or any integer.
To use Float() one must import Float class from sympy package first. The float method was able to represent an Integer into floating-point numbers and can able to limit the digits after the decimal point. It is also capable to represent scientific notations into numbers.
Python3
# import Float class from sympy from sympy import Float # converting integer to float print ( Float ( 5 )) # limiting the digits print ( Float ( 22.7 )) print ( Float ( 22.7 , 4 )) # Scientific notation to number format print ( Float ( '99.99E1' )) |
Output
5.00000000000000 22.7000000000000 22.70 999.900000000000
What is the number class in SymPy?
Number class is represented atomic numbers in SymPy Python. It has three subclasses. They are Float, Rational, and Integer. These subclasses are used to represent different kinds of numbers like integers, floating decimals, and rational numbers. There are also some predefined singleton objects that represent NaN, Infinity, and imaginary numbers.