Aliks

anyone know if in signed binary arithmetic, I'm supposed to carry the numbers into the sign bit, or is that "outside" the calculation?

ie. if I had a 3 bit (without sign) signed number, 111, and added 1...

would I have 000 and carry the 1 into the sign bit?

ie. if I had a 3 bit (without sign) signed number, 111, and added 1...

would I have 000 and carry the 1 into the sign bit?

tiocsti

wikipedia for twos complement

Aliks

its not twos complement though

its signed

twos comp is for unsigned

its signed

twos comp is for unsigned

tiocsti

(Action) shakes his head

Aliks

?

or at least that's my understanding

I was given different instructions for figuring out signed numbers

or at least that's my understanding

I was given different instructions for figuring out signed numbers

QuantumG

your understanding is akin to Bart Simpsons understanding of sex.

"the birds are singing, bees are trying to have sex with them", as is my understanding.

"the birds are singing, bees are trying to have sex with them", as is my understanding.

Aliks

lol right

QuantumG

two's complement is how signed numbers are represented in most computers today.

(or at least, most computers I can think of)

(or at least, most computers I can think of)

Aliks

right

but this is for a class

lol

but this is for a class

lol

QuantumG

so, if you have a 3 bit number, 111, and it was unsigned, and you added 1 you'd get 0.

Aliks

right

QuantumG

shockingly, if you had a 3 bit number, and it was signed, it would represent -1.. and adding 1 to that would give you, 0

Aliks

well, is there any case in which it would produce an incorrect result?

to just add them normally?

to just add them normally?

QuantumG

whereas 111 unsigned would represent 7, and adding 1 would give you, 0, I'd call that "wrong"

Aliks

right, overflow

QuantumG

yep, great, I hope you understand how I've done your homework for you.

Aliks

you havent

lol

I wish you had, but that doesnt answer my question

lets say I have (0)111 where 0 is the sign-magnitude bit, so it's positive

if I add (0)001, do I get (1)000 ?

lol

I wish you had, but that doesnt answer my question

lets say I have (0)111 where 0 is the sign-magnitude bit, so it's positive

if I add (0)001, do I get (1)000 ?

QuantumG

yes

you'd get (1)000

you'd get (1)000

Aliks

so basically I get a screwed up overflow that changes the sign-magnitude bit

QuantumG

and that would be "wrong" too

Aliks

instead of getting (0)000

I was wondering if it would only cause overflow on the rightmost 3

so just to confirm, I do carry into the sign magnitude bit

I was wondering if it would only cause overflow on the rightmost 3

so just to confirm, I do carry into the sign magnitude bit

QuantumG

the processor doesn't know whether a register contains a signed or unsigned value.

it doesn't care.

it doesn't care.

Aliks

ahhhh

QuantumG

it just adds one and it's your problem.

Aliks

duh... I'm an idiot

thanks for reminding me of this obvious fact

lol

dont know what I was thinking

however, reading my book it just doesnt seem to say that.... gahh

thanks for reminding me of this obvious fact

lol

dont know what I was thinking

however, reading my book it just doesnt seem to say that.... gahh

QuantumG

don't confuse the overflow bit with the sign bit

Aliks

"Consider the rule for adding two signed numbers: If the two numbers have the same sign, add and use that sign as the sign of the result. If they have different signs, subtract the smaller magnitude from the larger and give the result the sign of the larger."

QuantumG

the sign bit is just the most significant bit of the register.. the overflow bit is part of a seperate flags register (typically)

Aliks

right... when doing signed arithmatic though, there's no special instructions used to make it follow the quoted rules?

as opposed to normal rules?

as opposed to normal rules?

QuantumG

there's no need.. that stuff is just for humans.

Aliks

ah

so they're not actually describing the computational process

they're just telling me how to figure it out

so they're not actually describing the computational process

they're just telling me how to figure it out

QuantumG

yup

Aliks

buh, I wish they would just give me the computation and let me worry about figuring it out

tiocsti

theres usually some branch support for signed vs unsigned, but thats basically it

Aliks

tiocsti, "branch support"?

tiocsti

the concept of 'above' and 'below' will vary depending on whether its signed or unsigned

Aliks

right

tiocsti

or rather, whether its treated as signed or unsigned

Aliks

with you so far

QuantumG

yeah.. and again, the names are just for human use..

"jump if above" really means "jump if certain bits in the flag register are set"

"jump if above" really means "jump if certain bits in the flag register are set"

Aliks

yeah I realize that its all symbolic..

QuantumG

and how those bits are set tends to correspond to "above" when you use them correctly.

tiocsti

yup

all the branches are just evaluating the flags register (or equivilant)

all the branches are just evaluating the flags register (or equivilant)