Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help me with a logic equation in C

Status
Not open for further replies.

leonake

Newbie level 3
Joined
Nov 20, 2004
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
38
Message for otuzsubat

Hi otuzsubat!
I saw a message from you about tips and tricks in C programming and I consider you a great programmer.
Could you clarify a question for me?
y*=2.25 means y = (y << 1) + (y >> 2) or y = (y << 1) + (y >> 3)
Think a litlle bit. Maby I wrong.
Thanks a lot. See you next time.
 

Re: Message for otuzsubat

Do you mean y=2.25y?
The RHS is just (2^1)y + (2^-2)y
If so, then your first statement is correct. It's a common trick to make base-2 multiplication of addition even more efficient. In digital circuits, such a trick is even more widely used since hardware multipliers are costly but shift-registers arent.
 

Re: Message for otuzsubat

leonake said:
Hi checkmate!

In our case y is the same variable in memory. Shifting y means

y << 1 => y x 2 => y was modified in memory
after that
y >> 3 => y / 8 => y(initial) x 0.25

Good luck
Hi,

could you clarify what language you are using? Because I naturally assumed it to be C/C++.

Or maybe you are assuming instead
y = (y <<= 1) + (y >>= 3)
Then the new y value would be 0.375 of the original y value as the evaluation precedence is from R-to-L.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top