Shr and Shl dont work as expected

Please report bugs.

Shr and Shl dont work as expected

Postby udo.killermann » Wed Nov 17, 2010 7:46 am

Bernd,

when I run the following code it works counter-intuitive to the things I learned with C and Assembler:

Code: Select all
Event AwakeFromNib()
  Dim myInt As Integer
  Dim result As Integer
 
  myInt = 0x1f
  result = myInt Shr 4 ' I expect to get 0x01
  Log("result: ",Hex(result))
 
  result = myInt Shl 4 ' I expect to get 0x1f0
  Log("result: ",Hex(result))

End Event


The output reads:
Code: Select all
result:  1F0
result:  1


Shr means to me: move the bit pattern to the right, in direction of the least significant bits (the value should decrease using this operator)
Shl means to me: move the bit pattern to the left, in direction of the most significant bits (the value should increase using this operator)

I thinks this is an error in the runtime.

Regards
Udo
--------------
MacBook (2GHz, 4 GByte) - Lion (10.7.3)
started Objective Basic coding in April 2010 - still enjoy it ;-)
udo.killermann
 
Posts: 247
Joined: Thu Apr 08, 2010 6:46 am
Location: Hannover, Germany

Return to Bug Reports (Xcode 3)

Who is online

Users browsing this forum: No registered users and 1 guest