in reply to Re: Simple arithmetic?
in thread Simple arithmetic?

Inspired by previous answers.

I like your way of incorporating hdb's powers-of-two observation into the GCD() calculation.

the absence of bugs is totally not guaranteed

Understood. It's my responsibility to test code I use.

It stands up to all the likely scenarios (for my application) that I've tested. Thank you.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

Replies are listed 'Best First'.
Re^3: Simple arithmetic?
by hdb (Monsignor) on Mar 08, 2015 at 12:47 UTC

    Of course, my post came later, so the observation is this Anonymus Monk's own original observation. If in addition, as you comment above, R is prime (different from 2) or only odd, then the LCM is always 4096*R, so the whole discussion redundant...

      Of course, my post came later, so the observation is this Anonymus Monk's own original observation.
      No, I did mean 'answers' - both of them (the first one doesn't count, of course :) I'm kind of ungood at math - that's the reason for bitshifts, they're more 'visual' :)