News for hackers. Stuff that matters.
Re:How Rust 1.26 more than tripled the speed of my code by OskarS on Monday May 14, 2018 @09:53AM (#17065500)
That's how floats work, not ints. Unsigned integers more or less always wrap on overflow, which is what you want, generally speaking. Essentially, the operation is carried out modulo the size of the type.

For signed integers, overflow is undefined in C/C++, but generally results in wrapping as well.

Re:How Rust 1.26 more than tripled the speed of my code by chaosite on Monday May 14, 2018 @10:11AM (#17065659)
We're talking about Rust, not C/C++.
Re:How Rust 1.26 more than tripled the speed of my code by gpm on Monday May 14, 2018 @10:55AM (#17066056)
Just to record the difference.

Unsigned and signed overflow in rust are both well defined to do one of two things, panic or wrap. If debug assertions are enabled they are defined to panic. In practice if debug assertions are not enabled they will wrap, but I believe that is technically subject to change (into a panic). It will realistically only change if the hardware gets much better at catching overflows quickly.

A panic is usually like a exception that you are really not expected to ever catch except at thread boundaries. You can turn them into a immediate process exit with a compiler flag.

Re:How Rust 1.26 more than tripled the speed of my code by steveklabnik on Monday May 14, 2018 @03:48PM (#17068830)
> I believe that is technically subject to change

Yes, that's correct.

Re:How Rust 1.26 more than tripled the speed of my code by mmirate on Monday May 14, 2018 @02:16PM (#17067966)
> except at thread boundaries

Also at FFI boundaries. (i.e. a panicky Rust function, supplied to foreign code as a callback)

Re:How Rust 1.26 more than tripled the speed of my code by OskarS on Monday May 14, 2018 @10:26AM (#17065791)
Yeah, but I interpreted the question as "is that how it should work?", and then it's useful to compare with different languages. My point was that this is standard behaviour, but there's a slight quirk in C when the ints are signed.