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.

how can i shift left an integer?

Status
Not open for further replies.

jony

Newbie level 5
Joined
Feb 21, 2005
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,362
i need to shift left an integer
652585432=>6525.
just to cut off the 5 left numbers
without the floating point
can anyone help me?
 

What programming/HDL language are you using?

Are those decimal numbers? If it's decimal, is it stored as binary or BCD? You may need to do integer division, like this in C: 652585432/100000
 

hi,
division algorithms are complex.if u can afford some errors(apprximation to values) u can just use shift right function in vhdl(shr function).
 

viswa said:
hi,
division algorithms are complex.if u can afford some errors(apprximation to values) u can just use shift right function in vhdl(shr function).
I beg to differ here ... if the number is in binary then shr will produce a value way off limit. If the represantation is in bcd that's cake walk ... just shift it by 4* (no. of digits to be dropped)
 

hi semiconductorman,
but if u have ur number in bcd format,wont it be a headache to convert ur resulting numbers from binary format to bcd after each and every operation?[/quote]
 

Some computers/calculators do all their arithmetic in BCD, so it never has to convert to/from binary.
 

you can store them in registers and shift them directly.

jony said:
i need to shift left an integer
652585432=>6525.
just to cut off the 5 left numbers
without the floating point
can anyone help me?
 

I don't think it's possible to shift an integer number in this way.... should be in hex format... for example,,,
if you have this number 23 = 00010111 .... there is no way that you can shift this number to get just the 2, or 3 and leave the other. You should work in HEX or any bit vector format, to see clearly which bits you want to shift.
In your case you have this number "652585432", to store this number you'll need a 30-bit register... when you store it, you can easily shift it left or right.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top