to expand a 13 bit negative two's complement number to a 16 bit number bits 13,14 an 15 need to be set accordingly
in general the "sign bit" needs to be extended to the new width
so 1 0000 1111 0000 becomes 1111 0000 1111 0000 qed -3856
![]()
to expand a 13 bit negative two's complement number to a 16 bit number bits 13,14 an 15 need to be set accordingly
in general the "sign bit" needs to be extended to the new width
so 1 0000 1111 0000 becomes 1111 0000 1111 0000 qed -3856
![]()
Warning I'm not a teacher
Yes, Richard is correct. I forgot to mention you have to adjust the value to the byte, word or whatever width you have.
So the sign is the left most bit but the rest should also be 1. Remember we reverse the bits to get the absolute value disregarding the left most, sign bit.
Seems confusing at first, but has its logic.
Ioannis
Last edited by Ioannis; - 9th February 2024 at 12:11.
To convert a 2's compliment negative value to a positive number, invert all the bits (NOT) and add 1.Remember we reverse the bits to get the absolute value disregarding the left most, sign bit
For example 2's compliment -1 = FFFF
invert = 0000, add 1 = 0001
I was reffering to the left most bits but yes. Absolutely correct, to convert a positive to negative after reversing all bits you add one.
Ioannis
Bookmarks