News for hackers. Stuff that matters.
Re:How Rust 1.26 more than tripled the speed of my code by littlestymaar on Monday May 14, 2018 @09:56AM (#17065521)
If you just keep the higher 64 bits, what kind of sense does it make ? We're talking about integer here, not float.

At least, keeping the lower 64 bits is the usual overflow behavior and if the result of the multiplication fits in 64 bits it just works fine.

Re:How Rust 1.26 more than tripled the speed of my code by barrkel on Monday May 14, 2018 @10:18AM (#17065723)
There are cases for keeping just the high bits.

For example, many language runtime libraries have pseudo random number generators (PRNGs) use a 32-bit linear congruential generator (LCG). Suppose you want to create a rand(n) function which returns an integer between 0 and n-1. One good way of doing this is multiplying the lcg_output (a 32-bit unsigned integer) by n, and returning the high 32 bits.

It's better to do this than a modulus operation because the low bits on LCG sequences are highly predictable.

(This is how the Delphi Random(n) function works.)