Math Is Fun Forum
  Discussion about math, puzzles, games and fun.   Useful symbols: √ ∞ ≠ ≤ ≥ ≈ ⇒ ∈ Δ θ ∴ ∑ ∫ π -

Login

Username

Password

Not registered yet?

Post a reply

Go back

Write your message and submit
:) :| :( :D :o ;) :/ :P :lol: :mad: :rolleyes: :cool: | :dizzy :eek :kiss :roflol :rolleyes :shame :down :up :touched :sleep :wave :swear :tongue :what :faint :dunno
Options

Go back

Topic review (newest first)

MathsIsFun
2005-04-07 09:51:06

I recall using integer division in the past. It had special methods that may suit you.

Now if I could only find what I did with it ....

... I did find this: http://www.bearcave.com/software/divide.htm , the author has some C code that might do it for you.

The central part of his code has:

  while (remainder < divisor) {
    bit = (dividend & 0x80000000) >> 31;
    remainder = (remainder << 1) | bit;
    d = dividend;
    dividend = dividend << 1;
    num_bits--;
  }

(he says that always goes one step too far, so he just backs up once.)

Is that what you were looking for?

AV
2005-04-07 09:30:18

You are given a number n and you have to find if its divisble by 3 but the catch is you cant use mod or division operations
i am looking for something using binary arithmetic

Board footer

Powered by FluxBB