|
-
October 12th, 1999, 11:57 PM
#1
How we can implement right shifting a word in VB ?... pl help
Dear All,
How we can implement a right shifting of a word in VB?/// please heplp me
Thanks in advance
Kareem.
-
October 13th, 1999, 01:22 AM
#2
Re: How we can implement right shifting a word in VB ?... pl help
dim w as long
'Don't instanciate to "Integer" due to overflow problems
w=&h89ab
'This is now a word(2bytes long)
w=w/2
'Division by 2 is right shift by 1 bit
'Division by 2 raised to 8 is rightshift by 1 byte
'Multiplication by 2 is leftshift by 1 bit, and so on
OK now, I hope.
Deepak
-
October 13th, 1999, 01:43 AM
#3
Re: How we can implement right shifting a word in VB ?... pl help
this code was published a while ago by (if I remember correctly) "Crazy D @ work"
private Function RShiftWord(byval w as Integer, byval c as Integer) as Integer
Dim dw as Long
If c = 0 then
RShiftWord = w
else
dw = w And &HFFFF&
dw = dw \ (2 ^ c)
RShiftWord = dw And &HFFFF&
End If
End Function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|