float¶
These represent machine-level double precision floating point numbers. You are at the mercy of the underlying machine architecture (and C or Java implementation) for the accepted range and handling of overflow. Python does not support single-precision floating point numbers; the savings in processor and memory usage that are usually the reason for using these is dwarfed by the overhead of using objects in Python, so there is no reason to complicate the language with two kinds of floating point numbers.
Floating point numbers are usually implemented using double in C; information about the precision and internal representation of floating point numbers for the machine on which your program is running is available in sys.float_info.
Constructors¶
- float()
- Returns an expression converted into a floating point number.
- literal syntax
- Initializes a new instance of the float type.
Scientific Notation¶
- e | E (scientific notation)
- Returns a float multiplied by the specified power of 10.
Methods¶
- as_integer_ratio
- Returns a pair of integers whose ratio is exactly equal to the original float and with a positive denominator.
- is_integer
- Returns True if the float instance is finite with integral value, and False otherwise.
- hex
- Returns a representation of a floating-point number as a hexadecimal string.
- fromhex
- Returns the float represented by a hexadecimal string s.