Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: More bit shifting issues
Boltar <boltar2003@yahoo.co.uk> writes:
> On Apr 1, 11:58 pm, "robertwess...@yahoo.com"
> <robertwess...@yahoo.com> wrote: 
>
> Well that begs the question of why the cpu integer div instruction
> doesn't simply check the divisors least significant bit to see if its
> set to zero (even) and if it is then use bit shifting to get the
> result. Same for multiply.

(Others have already mentioned that you need a power of 2, not just a
multiple of 2, but that doesn't invalidate the idea.)

A plausible explanation is that chip designers assume that most
multiplications and divisions by constant powers of 2 will be
optimized to shifts by the compiler.  Thus such a hardware check will
benefit only cases where a run-time value just happens to be a power
of 2, and will likely slow down *all* multiplications and divisions.

On the other hand, I'm no hardware expert.  Perhaps such a test can be
done in parallel without slowing anything down.  If so, perhaps it's
already being done (it would be invisible to user code, or nearly so).

--
Keith Thompson (The_Other_Keith) <kst-u@mib.org>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

Report this thread to moderator Post Follow-up to this message
Old Post
Keith Thompson
04-03-08 03:07 AM


Sponsored Links




Last Thread Next Thread Next
Pages (3): « 1 2 [3]
Search this forum -> 
Post New Thread

C archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 10:49 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.