Representing Negative Numbers.

Negative numbers are represented internally in what is called "two's complement form", which is the inverse of the positive number.

The procedure for converting a positive binary number to two's complement form is as follows:

Decimal Number   = 13
Binary Number    = 0000 1101
Swapped Bits     = 1111 0010
Now add 1        = 0000 0001
                   ---------
Two's Compliment = 1111 0011
 

Enter a Decimal number in the range 0 - 1879,048,191 to view its Two's Compliment form, which will be returned in the form relevant to a 4-byte field.

</COMMENT>

If it were necessary to code actual bit patterns it would be a chore. Fortunately when coding there is a shorthand form for indicating two's complement which is 64-n, i.e. 64-1 generates a field containing minus one in two's complement form.

Copyright © KMS-IT Limited 2002, 2003