|
From: robert.corbett on 1 Feb 2008 22:41 On Feb 1, 8:51 am, nos...(a)see.signature (Richard Maine) wrote: > 1. The Fortran model is a sign-magnitude one. It is symmetric > with respect to sign. Sign magnitude is common in actual > floating point representations. It is rare for integers. > Most integers today are done in 2's complement (if I didn't > get that term backwards, which I might have; I have to think > a bit to get 2's complement versus 1's complement straight). According to Knuth vol.2, Section 4.1, it is "ones' complement" vs. "two's complement." Ones' complement is the bitwise complement, i.e., an exlusive or with ones. Two's complement is the value of the other bits minus a power of two. For unsigned notation, ones' complement notation and two's complement notation, the bits other than the high-order bit are all treated the same. In unsigned notation, the high-order bit is multiplied by two raised to the power one less than the number of bits. In two's complement notation, the high-order bit is multiplied by the negation of two raised to the power one less than the number of bits. In ones' complement notation, the high-order bit is multipled by the negation of the quantity two raised to the power one less than the number of bits minus one. For example, given the 32-bit number all of whose bits are ones, its unsigned value is 2^31 + (2^31 - 1) = 4294967295 its ones' complement value is -(2^31 - 1) + (2^31 - 1) = 0 and its two's complement value is -2^31 + (2^31 - 1) = -1 Bob Corbett
|
Pages: 1 Prev: Wrong code, I could not find the error Next: Fortran user models Intra-Day Stock Market |