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