[英]Unsigned integer overflow in Rust
I am a beginner to Rust. 我是Rust的初学者。 In the code: 在代码中:
println!("{}", 4400202385408u64 * 34359738368u64);
The rust compiler gives me the following error: rust编译器给我以下错误:
error: attempt to multiply with overflow
despite the fact that the result of the multiplication is within std::u64::MAX
尽管乘法结果在std::u64::MAX
Can someone point me to what is happening? 有人可以指出我的情况吗?
despite the fact that the result of the multiplication is within std::u64::MAX 尽管乘法结果在std :: u64 :: MAX之内
Pretty sure it's not. 可以肯定的不是。
Converting to hex, you're doing 0x40080800800 * 0x800000000. 转换为十六进制,您正在执行0x40080800800 * 0x800000000。 They're both individually well over a u32 MAX, so when you multiply them together they're well over a u64 max. 它们各自在u32 MAX上都很好,因此当您将它们相乘时,它们在u64 max上都很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.