Using bigger integers

The i128_type feature gives us the i128 and u128 integers, which work the same way as i64 and u64 types, but with 128 bits instead of 64, which gives them more capacity. They have the same API as the rest of the integers, so you can perform the same kind of operations. Sometimes it's great to have a bigger, full-precision integer and, in this case, since it uses LLVM intrinsics, the type is almost as lightweight as a u64 or i64 (more or less double the processing time in a 64-bit machine; it should be around the same in a 128-bit machine). A simple example is given in the main documentation:

#![feature(i128_type)]fn main() {    assert_eq!(1u128 + 1u128, 2u128);    assert_eq!(u128::min_value(), 0); assert_eq!(u128::max_value(), ...

Get Rust High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.