This may be sound like a stupid question, because, of course, it can be negative and, as Wikipedia states:

A numeric variable is signed if it can represent both positive and negative numbers, and unsigned if it can only represent non-negative numbers (zero or positive numbers).

But is it really? Because it doesn't work like normal signed integer, because doesn't really have a sign, it's just an unsigned integer starting at a negative point, it seems to me. I guess the first character could indicate whether it's negative xor positive / zero.

For people who don't remember CS class:

  • exponent of -127: 0000 0000
  • exponent of zero: 0111 1111
  • exponent of one: 1000 0000
  • exponent of 128: 1111 1111
  • 1
    $\begingroup$ I don't understand your question. As you say, the exponent field in floating point numbers is able to represent negative numbers. It's still a negative number, whether you call it "minus ten" or "six more than minus sixteen". $\endgroup$ – David Richerby Feb 26 '17 at 21:07

This is mostly a matter of interpretation. For IEEE 754 floating point numbers (one of the most common implementations), an exponent bias is used:

In IEEE 754 floating point numbers, the exponent is biased in the engineering sense of the word – the value stored is offset from the actual value by the exponent bias. Biasing is done because exponents have to be signed values in order to be able to represent both tiny and huge values, but two's complement, the usual representation for signed values, would make comparison harder.

To solve this problem the exponent is biased before being stored, by adjusting its value to put it within an unsigned range suitable for comparison.

For floating point numbers with single-precision, the effective exponent has 8 bits and ranges from -126 to 127. However, the internal exponent ranges from 1 to 254, meaning that 127 has been added to the effective exponent. (This means it is valid to say that the exponents of floating point numbers are stored as unsigned integers, even though this is a matter of interpretation.)

In addition to the reasons outlined above, another good reason for this encoding is that two special exponents are required for floating point encoding according to IEEE 754: Floating point numbers can also store the values Infinity, NaN and denormalized values which would be too small to store them in the usual format.

The special constants used are the internal exponents $0$ and $2^r-1$ (where $r$ is the number of bits of the exponent), so in binary $0...0$ and $1...1$. These values are easy to recognize. Note that these exponents belong to effective exponents that are barely ever used. If we had used the internal exponent $0$ without shifting the range, it would be the same as the effective exponent $0$, making it difficult to encode common number ranges.


Whether a variable is signed or unsigned is a semantic feature. Floating point exponents are interpreted as signed numbers, so they are signed variables, irrespective of encoding details.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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