Archived

This topic is now archived and is closed to further replies.

vbisme

Divide by 2, right shift

Recommended Posts

I don''t think you can divide just by using bitwise logic. But bit-shifting is pretty darn fast, so I don''t see why that wouldn''t be good enough. In fact, using multiple logical operations would undoubtedly be SLOWER!

Share this post


Link to post
Share on other sites
I''m tested for algorithm on limited machine instructions. Like for left shift or multiply by two, you would simply ADD the number by itself. There is away to do right shift, which I don''t know.

Share this post


Link to post
Share on other sites
There are some tricks (although mainly adds and subs) you can do by mixing 1''s complement operations with 2''s complement ops - (NOT vs NEG etc) and there are a few things you can do with masking against a few constants, but as mentioned above it''ll be slower than just using a bitwise shift (or using the FPU divide with good pipelining to hide the overhead).

--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites