How do 128-bit integers i128 and u128 work in Rust on a 64-bit system?
Hello everyone! I started learning Rust and came across an interesting point: the language has built-in 128-bit integers (`i128` and `u128`). I have a 64-bit processor (AMD Ryzen), and I don't understand how a processor that operates with 64-bit registers can work with 128-bit numbers at the hardware level? Doesn't this require special CPU support?\n\nI wrote a simple code:\n\n```rust\nfn main() {\n let a: i128 = 170141183460469231731687303715884105727;\n let b: i128 = 1;\n let c = a + b;\n println!("Result: {}", c);\n}\n```\n\nThe code works, but I want to understand:\n1. How does the compiler handle such operations? Does it emulate them using multiple 64-bit instructions?\n2. Is there a performance loss compared to `i64`?\n3. When does it make sense to use `i128`, and when should
No answers yet.
Log in to leave an answer
Blogs