Message305620
Mentioning “sufficient space” is nice because it relieves concerns about overflows and running out of bits. But “sufficient space for the absolute value” seems tricky if not misleading, because two’s complement does not directly record the absolute value, and extreme values like -128 need less bits in two’s complement (7 + sign) than with a separate magnitude (8 + sign).
What about:
“Bitwise operations have the same result as calculations using two’s complement with a bit-width large enough to avoid overflows.”
I’m not sure that a precise definition is necessary, but I would say a bit-width k must be chosen such that -2**(k-1) <= x < 2**(k-1) for all operands x (and for the left shift x << n, the width must be k + n). |
|
Date |
User |
Action |
Args |
2017-11-06 07:05:44 | martin.panter | link | issue29710 messages |
2017-11-06 07:05:43 | martin.panter | create | |
|