Is the expression (BC + AD)<<16 equivalent to (BC << 16) + (AD <<16)?
From some examples which I tried it seems to be true but not sure at all
Is the expression (BC + AD)<<16 equivalent to (BC << 16) + (AD <<16)?
From some examples which I tried it seems to be true but not sure at all
They are equivalent. The width of all operands get extended to the size of the largest operand before any operation occurs. As long as the width of one of BC or AD is 16 bits wider than the value being shifted, then what you wrote is mathematically equivalent to
\$(BC + AD)×2^{16} = BC×2^{16}+ AD×2^{16}\$
If the width of the largest operand is not wide enough to hold the shifted value, then it gets truncated to that width.
Yes, as long as the width of the left-hand side you are assigning to is the same in both cases.
If the width of the left-hand side is smaller than the right-hand side, the value will be truncated to the Least Significant bits. In other words, the Most Significant Bits are discarded.
The width of the operands are extended to the same size as that of the largest operand, and then the operations are performed. When extending the operands on the right-hand side, zeros are filled in the Most Significant bits, and then the operations are performed.
In the case of the addition operator, the operand includes the left-hand side. The width of the left-hand side is fixed.