Decimal conversions to and from integers #
IEEE 754-2019 §§5.4.1, 5.8 and 7.2(j) require rounding to an integer before checking its destination range. In particular, a negative fraction can convert to unsigned zero, and a value just outside an endpoint can round into range.
The ten explicit-direction operations share the exact coefficient rounder used
by decimal integral rounding. No intervening decimal precision rounding occurs.
The Exact variants signal inexact only on successful conversion. Every NaN,
infinity, or rounded integer outside the destination range instead raises invalid.
This binding documents integer zero as its default invalid delivery and reports
invalid explicitly in the result status.
Signed destinations use the existing two's-complement FixedInt bounds.
Unsigned destinations use the range of BitVec. Width zero denotes only zero
in both cases. Integer sources have no signed zero and therefore convert to +0.
Signedness and width are independent of the decimal source format.
Instances For
Instances For
Round an exact rational once to the integer grid, with sign-sensitive directed rounding.
Instances For
This binding's invalid integer result is zero, with only the invalid flag set.
Instances For
Shared conversion kernel. signalInexact selects exact versus quiet conversion;
it does not change the rounding direction or the delivered integer.
Instances For
Nearest integer, ties to even; suppress inexact, but report invalid conversion.
Instances For
Nearest integer, ties away from zero; suppress inexact, but report invalid conversion.
Instances For
Round toward zero; suppress inexact, but report invalid conversion.
Instances For
Round toward positive infinity; suppress inexact, but report invalid conversion.
Instances For
Round toward negative infinity; suppress inexact, but report invalid conversion.
Instances For
Nearest integer, ties to even; report inexact precisely when a valid result changes value.
Instances For
Nearest integer, ties away from zero; report inexact on a valid numerical change.
Instances For
Round toward zero; report inexact on a valid numerical change.
Instances For
Round toward positive infinity; report inexact on a valid numerical change.
Instances For
Round toward negative infinity; report inexact on a valid numerical change.
Instances For
Convert an arbitrary signed integer directly to a decimal destination, with preferred quantum zero and one destination rounding (§5.4.1).
Instances For
Convert a two's-complement source by its exact signed value.
Instances For
Convert an unsigned word by its exact nonnegative value.
Instances For
Pack a signed conversion into the existing fixed-width carrier, retaining its status. The conversion has already checked the range; packing does not implement wraparound conversion.
Instances For
Pack an unsigned conversion after its range check.