Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binary Addition. Is it overflow?

Binary values are in 2s Complement form.

If I am to add 110001 (-15) and 101110 (-18), and the answer has to be stored in a 6-bit integer, is this an underflow/overflow.

like image 551
xbonez Avatar asked Jul 15 '26 04:07

xbonez


1 Answers

This is overflow, your professor is correct. You are storing more bits that can be held in the alloted space (even though the number that the bits represent is negative.)

Underflow is when bits get zero'd out through shifting on big math. Very common in fixed point math. Divide a very small number by a very big number and you will quite often get a 0. That is underflow.

like image 146
Michael Dorgan Avatar answered Jul 18 '26 17:07

Michael Dorgan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!