Function saturate [src]

Saturate an integer to a number of bits, following 2s-complement semantics. r may alias a. Asserts r has enough storage to store the result. The upper bound is calcTwosCompLimbCount(a.len).

Prototype

pub fn saturate(r: *Mutable, a: Const, signedness: Signedness, bit_count: usize) void

Parameters

r: *Mutablea: Constsignedness: Signednessbit_count: usize

Source

pub fn saturate(r: *Mutable, a: Const, signedness: Signedness, bit_count: usize) void { if (!a.fitsInTwosComp(signedness, bit_count)) { r.setTwosCompIntLimit(if (r.positive) .max else .min, signedness, bit_count); } }