Skip to main content
gamedev.net
🔒 Locked

bitwise shift question

Started by _nomad_ Jul 11, 2004 at 10:13 PM 1 replies 300+ views
Original Post
_nomad_
_nomad_
is this correct: (x*40) is equal to ((x<<5) + (x<<3)) if not, how to convert to bitwise shifts, multiplications not powers of two? Thanks.
thedevdan
thedevdan
Yes, assuming x is integral (not float).

EDIT: Now it makes sense!
Not giving is not stealing.
TangentZ
TangentZ
Quote:
Original post by _nomad_
((x<<5) + (x<<3))


Break it down:

x << 5 ==> x * 32
x << 3 ==> x * 8

(x * 32) + (x * 8) ==> x * (32 + 8) ==> x * 40
神はサイコロを振らない!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.