Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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