feanor_math::integer

Function int_cast

Source
pub fn int_cast<T: RingStore, F: RingStore>(
    value: El<F>,
    to: T,
    from: F,
) -> El<T>
Expand description

Conversion of elements between two rings representing the integers ZZ.

The underlying conversion functionality is the same as provided by IntCast, and indirectly also by CanHomFrom and CanIsoFromTo.

ยงExample

let ZZi64 = StaticRing::<i64>::RING;
let ZZbig = BigIntRing::RING;
let ZZi8 = StaticRing::<i8>::RING;
assert_eq!(7, int_cast(7, ZZi64, ZZi8));
assert_eq!(65536, int_cast(ZZbig.power_of_two(16), ZZi64, ZZbig));
assert_el_eq!(ZZbig, ZZbig.power_of_two(16), int_cast(65536, ZZbig, ZZi64));