PDA

View Full Version : unsigned...


DELOCH
02-12-2008, 02:58 AM
ok this question has been bugging me for a LOOOOOONG time

I understand that
~30 + 1 = -30

but on the other hand

30: 0001 1110

but ~30 + 1 is
1111 .... 1110 0010

lets say 30 is a byte

and -30 in byte form would be 1110 0002
and 1110 0010 is equal to 226...

so basically the -30 is equal to 226...

i still don't get where the logic comes in... because that isn't true

how does computer select from -30 or 226, is it something to do with SF flag?
:\

liorean
02-12-2008, 06:51 AM
how does computer select from -30 or 226, is it something to do with SF flag?:\Just from looking at the value of the bits in the variable, you can't tell. The compiler knows the declared type for the variable, so when handling the variable, it knows to use methods interpreting it as -30 or as 226 depending on the type.