External Publication
Visit Post

Infinite precision intermediate arithmetic: how much would break?

Rust Internals [Unofficial] June 9, 2026
Source

Vorpal:

While this might work for arithmetic (though not when retrofitted), what about bit twiddling? It seems error prone to me if the compiler tries to guess the integer width in that type of code.

it's totally possible to figure out the exact range of bit-twiddled values (when working an operator at a time), and from the range you can deduce the width in bits. it is a bit complicated so I'm not going to write it all out here, but e.g. !v is just -1 - v and v << s is just v * 2.pow(s).

I'd want ranged integers int<min..=max> and also arbitrary fixed bit-width integers u/i.

Discussion in the ATmosphere

Loading comments...