PyDocs

Nav

Numeric and Mathematical Modules

Decimal.from_float

decimal

classmethod of Decimal · Added in 3.1
  • Decimal.from_float(f, /)
Alternative constructor that only accepts instances of float or int.
1 Example
>>> Decimal.from_float(0.1)
Decimal('0.1000000000000000055511151231257827021181583404541015625')
>>> Decimal.from_float(float('nan'))
Decimal('NaN')
>>> Decimal.from_float(float('inf'))
Decimal('Infinity')
>>> Decimal.from_float(float('-inf'))
Decimal('-Infinity')
from the Python docs
See Also
No see-alsos for decimal/Decimal.from_float
0 Notes
No notes for Decimal.from_float