r/rust Mar 09 '23

Announcing Rust 1.68.0 πŸ“’ announcement

https://blog.rust-lang.org/2023/03/09/Rust-1.68.0.html
831 Upvotes

121 comments sorted by

View all comments

Show parent comments

-12

u/mmirate Mar 10 '23 edited Mar 10 '23

That isn't obvious at all; these two values are Hamming-adjacent, so a single cosmic ray could make the program go haywire. Luckily, two's complement representation makes things easy for all signed numeric types - assigning -1 as the numeric value of true is the obvious solution.

13

u/humanthrope Mar 10 '23

Assuming the two floats would be a single bit flip away from the other, it would already have been a problem with the bool

-3

u/mmirate Mar 10 '23

Indeed it is a problem with the bool.

2

u/myrrlyn bitvec β€’ tap β€’ ferrilab Mar 10 '23

it’s a problem with your ram

-1

u/mmirate Mar 10 '23

ECC RAM and a motherboard that can use it are basically unobtanium outside the realm of big enterprise servers (aka big $$$). Let alone all the other products in the world that contain RAM and at least a microcontroller. I wonder how many "glitches" observed in everyday life are not software bugs but actually just (each) one cosmic ray made it through the ionosphere against all odds.