News for hackers. Stuff that matters.
Re:A Foray into Go Assembly Programming by libeclipse on Monday April 24, 2017 @02:54AM (#14182389)
> In this case, a divide by 3 is equivalent to multiplying by 0x55555556 and then taking the top half of the output.

What the fuck. That's amazing!

Re:A Foray into Go Assembly Programming by chris_overseas on Monday April 24, 2017 @04:32AM (#14182738)
In more general terms, take a look at Montgomery multiplication[1] which is where this trick originates. It's a common technique used by compilers to optimise away divisions.

[1] https://en.wikipedia.org/wiki/Montgomery_modular_multiplicat...

Re:A Foray into Go Assembly Programming by vardump on Monday April 24, 2017 @04:11AM (#14182653)
In that case, fixed point arithmetic might blow your mind. :)

https://en.wikipedia.org/wiki/Fixed-point_arithmetic