At 01:04 PM 2/26/98 -0800, you wrote: >>>On 23 Feb, jhobbs wrote: >>/I once knew a fast trick for divide by 3, but now I am unable to reproduce >>>/it. If someone can share it with me (and others) that would be great. >>>/ >>>/Take care -Jim > >>> Simple. To multiply by 3, double and add to original. To divide by 3, >>>just do the inverse! >>>-- Mel Evans > >>Could someone unfold that for a binary math newbie, please? >>/Morgan >>/ Morgan Olsson, MORGANS REGLERTEKNIK, SE-277 35 KIVIK, Sweden \ \ >>mrt@iname.com, ph: +46 (0)414 70741; fax +46 (0)414 70331 / > >Sure. > >Let's start with the number 5. In binary that is: > > 101 > >Since the place value of binary is two, you can double the number by shifting it >left one bit, like this: > >Old: 101 >New: 1010 > >Now you add it to the original number, like this > > > 1010 > + 101 > ------ > 1111 > >The result is the number 15, which is the answer to 5 * 3! > > >Later, > >Eric > Yeah, fine for multiplication, but that neat relationship doesn't hold for division, at least as far as I can see. Take 10/3 for example: 10 shifted down one is 5 now, what can you do to 5 to get 3.3333? It seems to me that Andy Warren had the best solution, do a series of divisions by powers of two until you get the accuracy you need. Sean +--------------------------------+ | Sean Breheny | | Amateur Radio Callsign: KA3YXM | | Electrical Engineering Student | +--------------------------------+ Fight injustice, please look at http://homepages.enterprise.net/toolan/joanandrews/ Personal page: http://www.people.cornell.edu/pages/shb7 mailto:shb7@cornell.edu Phone(USA): (607) 253-0315