-
January 16th, 2009, 01:06 PM
#1
[RESOLVED] Don't understand
this help link (No works in Firefox, only in IE)
ms-help://MS.VSCC.v90/MS.msdnexpress.v90.en/dv_vbalr/html/fdb93d25-81ba-417f-b808-41207bfb8440.htm
says:
Originally Posted by ms-help
"Arithmetic shifts are not circular, which means the bits shifted off one end of the result are not reintroduced at the other end. In an arithmetic left shift, the bits shifted beyond the range of the result data type are discarded, and the bit positions vacated on the right are set to zero."
But then gives an example:
Originally Posted by ms-help
Code:
Dim pattern As Short = 192
' The bit pattern is 0000 0000 1100 0000.
Dim result4 As Short
'...
result4 = pattern << 17
The results of the previous example are as follows:
...
result4 is 384 (0000 0001 1000 0000).
...
but that result is only possible if the Shift IS circular.
then it says:
Originally Posted by ms-help
The shift amount for result4 is calculated as 17 AND 15, which equals 1.
I don't get it.
[Vb.NET 2008 (ex Express)]
-
January 16th, 2009, 09:18 PM
#2
Re: Don't understand
WHY did you skip the important line on that page:
To prevent a shift by more bits than the result can hold, Visual Basic masks the value of amount with a size mask that corresponds to the data type of pattern. The binary AND of these values is used for the shift amount.
Therefore for a 16 bit wuantity, the maximum shift is 15, so
0001 0001 = 17
0000 1111 = 15
============
0000 0001 = 1
The Data is Shifted by 1 bit when you ask for 17....
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
January 20th, 2009, 07:00 AM
#3
Re: Don't understand
Originally Posted by TheCPUWizard
WHY did you skip the important line on that page:
...
That was!
(Answer: Because my English is poor...)
Thanks CPU. I gonna tell Gandalf of you.
[Vb.NET 2008 (ex Express)]
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
|