| Author |
Is >>>= Broken?
|
Darrin Cartwright
Ranch Hand
Joined: Dec 27, 2002
Posts: 107
|
|
Or am I just missing something. When I try to use the "right shift with zero extension" operator, I still get 1's filling in from the left. Can anyone tell me what I am doing wrong? Here is a little sample program: On the next to last line of this program I would expect 00000001 00000000 to be printed. Please help. The cattle are restless.
|
Life is good on the Ponderosa,<br />but mind where you step.
|
 |
Wirianto Djunaidi
Ranch Hand
Joined: Mar 20, 2001
Posts: 195
|
|
The reason is >>>= operate on int data type, so your number got converted into int during shift and you got the erroneous result when it was truncated back. If you had used You'll see the compiler give a warning regarding the lost of precision. If you change your data type to int, it will show the correct result. [ September 29, 2003: Message edited by: Wirianto Djunaidi ]
|
 |
 |
|
|
subject: Is >>>= Broken?
|
|
|