Create a new Decimal instance from float f. Unlike the Decimal.from_float() class method, this function observes the context limits.
>>> context = Context(prec=5, rounding=ROUND_DOWN) >>> context.create_decimal_from_float(math.pi) Decimal('3.1415') >>> context = Context(prec=5, traps=[Inexact]) >>> context.create_decimal_from_float(math.pi) Traceback (most recent call last): ... decimal.Inexact: None
decimal/Context.create_decimal_from_float
Context.create_decimal_from_float