PE> Well, on a signed-magnitude computer, the hardware
PE> manufacturers may have provided a shift-right which preserves
PE> the sign, so that -16 shifted 1 bit to the right becomes -8. It
PE> may make a lot of sense.
BL> Whaaat? How does the machine know it's a signed integer? It's just
BL> 32-bits in a register. Are you telling me that computer hardware has a
BL> list of ints, longints, char, words, arrays, and all that crap?
No, what it actually has (potentially, anyway) is a list of instructions
that assume the 32-bits represent a signed integer, or an unsigned integer.
E.g. the C64, from memory, had an ASR (arithmetic shift right) and a SHR
(shift right), the latter treating the register as unsigned. MVS had the
same, and I presume intel has the same (look it up). The compiler knows
whether the value is signed or unsigned, and generates the correct
instruction. BFN. Paul.
@EOT:
---
* Origin: X (3:711/934.9)
|