Forum Discussion
Altera_Forum
Honored Contributor
15 years agoOutput of "x^2 + y^2" from 2's complement to binary (with sign)
Hi, I am using a altmult_add megafunction to generate output of x^2 + y^2 for inputs x and y, where both x and y are 2's complements. I understand that the output would always be a positiv...
Altera_Forum
Honored Contributor
15 years agox/y = 8 bits signed
x^2/y^2 = 16 bits signed if we add these two numbers we get a 17 bit result. bit 17 is always zero because the number is always positive, so it can be dropped to give a 16 bit Unsigned number. If you need to add it to any -ve numbers you have to add the sign bit back on again (a '0') so it might be worth keeping it after all.