MCPcopy Index your code
hub / github.com/RustPython/RustPython / IEEEContext

Function IEEEContext

Lib/_pydecimal.py:422–440  ·  view source on GitHub ↗

Return a context object initialized to the proper values for one of the IEEE interchange formats. The argument must be a multiple of 32 and less than IEEE_CONTEXT_MAX_BITS.

(bits, /)

Source from the content-addressed store, hash-verified

420
421
422def IEEEContext(bits, /):
423 """
424 Return a context object initialized to the proper values for one of the
425 IEEE interchange formats. The argument must be a multiple of 32 and less
426 than IEEE_CONTEXT_MAX_BITS.
427 """
428 if bits <= 0 or bits > IEEE_CONTEXT_MAX_BITS or bits % 32:
429 raise ValueError("argument must be a multiple of 32, "
430 f"with a maximum of {IEEE_CONTEXT_MAX_BITS}")
431
432 ctx = Context()
433 ctx.prec = 9 * (bits//32) - 2
434 ctx.Emax = 3 * (1 << (bits//16 + 3))
435 ctx.Emin = 1 - ctx.Emax
436 ctx.rounding = ROUND_HALF_EVEN
437 ctx.clamp = 1
438 ctx.traps = dict.fromkeys(_signals, False)
439
440 return ctx
441
442
443##### Decimal class #######################################################

Callers 1

test_ieee_contextMethod · 0.85

Calls 2

ContextClass · 0.70
fromkeysMethod · 0.45

Tested by 1

test_ieee_contextMethod · 0.68