Squidge
Certified Guru
I'm writing a function to divide a number by 1.5. It should take an integer operand (which will always be in the range 0 - 4096) and give an integer result. Eg. Pass in 216, and get back 144.
At the moment, what I've got is this:
Result = ((Num/3)*2)
Which is fine, but I'd really like a faster way of dividing by 3 if possible.
Or perhaps someone has a way without using the divide?
I don't want to use any floating point (so dividing by multiplication is out I think), and ideally don't want to use masses of memory (so no 4096-byte table).
At the moment, what I've got is this:
Result = ((Num/3)*2)
Which is fine, but I'd really like a faster way of dividing by 3 if possible.
Or perhaps someone has a way without using the divide?
I don't want to use any floating point (so dividing by multiplication is out I think), and ideally don't want to use masses of memory (so no 4096-byte table).