|
-
Jul 12th, 2007, 06:15 AM
#1
Thread Starter
New Member
Bit operands - why???
Code:
x=37 , console.write(not x) = -38
Why?? If "not" operand is reversing bits from 0 to 1 and other way around how can result be -38?? 0001 should be 1110, or I'm so wrong?
-
Jul 12th, 2007, 06:21 AM
#2
Re: Bit operands - why???
Negative numbers are represented using Twos complement
-
Jul 12th, 2007, 07:01 AM
#3
Re: Bit operands - why???
It depends what data type you use. On the x86 platform, you can't store a 4-bit number; the smallest data type is a byte (8 bits).
~00000001 in a byte is 11111110, which in an unsigned byte is 254.
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
|