Re: A86: Negative numbers, sign bits, and the sign flag.


[Prev][Next][Index][Thread]

Re: A86: Negative numbers, sign bits, and the sign flag.






On Thu, 24 Jun 1999 23:27:35 EDT CurtG6@aol.com writes:
>
>	I have read that a negative byte is represented by counting 
>down from 
>255.  So -1 would be 254, -2 would be 253, etc.  But how do you know 
>if 
>%11111101 represents 253 or -2?  I have also read that bit 7 of a byte 

you don't.  to the processor, they're exactly the same (as long as you're
working with 8 bits) the only difference is how you choose to interpret
it.  there's basically two kinds of numbers, signed and unsigned.  if
you're using signed numbers, 8 bits can hold -127 to 128 and bit 7 is the
sign bit.  if you're using unsigned, it's 0 to 255 and the bit 7 is the
128ths place.

check it out:
255+1=256
%11111111+%00000001=%00000000 (bit 8 is lost to carry)

-1+1=0
%11111111+%00000001=%00000000 (carry doesn't mean much here)

>as -1 which goes back to my first question.)  And also, when and how 
>is the 
>sign flag affected and how can you check it?  Thanks for your help.

i'm not absolutely certain, but i believe the sign bit always reflects
bit 7 (of a/the last operation that affected it) and it's more or less
meaningless if you're using unsigned numbers.

-josh



___________________________________________________________________
Get the Internet just the way you want it.
Free software, free e-mail, and free Internet access for a month!
Try Juno Web: http://dl.www.juno.com/dynoget/tagj.