1

I prefer providing an example to explain the following paragraph:

However, since excess K representation using N bits has two parameters, K and N, you can pick K to be whatever you want. You can have more positive numbers than negative, not include zero, and so forth.

1 Answer 1

2

It means you can pick an arbitrary value for K. In Excess-K notation, you take your base 10 number and add K before converting to base 2.

For instance:

To represent the numbers -255 to -128,  N = 7,  K = 255  -- all numbers are negative 
To represent the numbers -100 to 27,    N = 7,  K = 100  -- more numbers are negative 
To represent the numbers -4 to 123,     N = 7,  K = 4    -- more numbers are positive 
To represent the numbers 42 to 169,     N = 7,  K = -42  -- all numbers are positive

The usefulness of Excess-K notation is that you can sort the numbers as if they were unsigned ints, unlike in twos-compliment where the negative numbers are sorted as bigger than positive numbers. This is used, along with other parts of the the IEEE Floating Point specification, so that you can interchange between (signed) ints and floats easily.

Interestingly, incrementing a float as if it were an int moves it away from zero to the closest number representable by a float, because adjacent floats have adjacent integer representations if they have the same sign. You can look at This post and others by the same author for more interesting floating point information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.