−0 (number)
From Wikipedia, the free encyclopedia
−0 is the representation of negative zero or minus zero, a number that exists in computing, in some signed number representations for integers, and in most floating point number representations. In mathematical terms there is no concept of a negative (or positive) zero, and −0 is identical to, and represented as, 0. In science, −0 may be used to denote a quantity which is less than zero, but which is too small in magnitude to be rounded down to −1. In statistical mechanics, certain systems in a state of population inversion may be considered to have an absolute temperature of −0.
Contents |
[edit] Representations
In a 1+7-bit sign-and-magnitude representation for integers, negative zero is represented by the binary value 10000000. In an 8-bit one's complement representation, negative zero is represented by the binary value 11111111. In IEEE 754 floating point numbers, negative zero is represented by the exponent and mantissa being zero and the sign bit being one.
In IBM's General Decimal Arithmetic encoding specification, a floating point representation that uses decimal arithmetic, negative zero is represented by an exponent being any valid exponent in the range for the encoding, the coefficient being (densely packed encoded) all zeros, and the sign bit being one.
In the now dominating representation of signed integers, two's complement, there is no negative zero, and that is one of the reasons this representation has become popular.
[edit] Properties and handling
In programming languages such as C, C#, C++, and Java, whilst it is possible to obtain negative zero as the result of an expression (for instance as the result of arithmetic underflow on a negative number), negative zero and positive zero compare equal. Thus a simple comparison is not sufficient to test whether a number is negative zero.
Instead, the copysign()
function defined by IEEE 754 can be used to copy the sign of the zero to some non-zero number.
The division operator can also be used to distinguish positive zero from negative zero:
- (for positive x)
- (for positive x)
Other operations involving negative zero:
- (for positive x)
- (for negative x)
- (for negative x)
- (for positive x)
[edit] Scientific uses
In meteorology, −0 can be used to indicate a temperature which is below zero (Fahrenheit or Celsius, depending on which scale is in use), which is often important for statistical reasons, but is not low enough to be rounded to −1. An example of such a temperature is −0.2 degrees; this cannot be listed as zero degrees, because temperatures of zero degrees are obviously not considered below zero. However, a tally of below-zero days is often a rudimentary statistic in comparing the coldness of winter seasons, so it cannot be ignored. It is not low enough to be rounded to −1, so it is recorded as −0.
In some contexts related to statistical mechanics, it is possible for systems to have a negative absolute temperature, but counterintuitively, these are not extremely cold, but rather extremely hot, hotter than any positive temperature. In this context, −0 is the hottest temperature there is.
[edit] References
- Floating point types. MSDN C# Language Specification. Retrieved on October 15, 2005.
- Division operator. MSDN C# Language Specification. Retrieved on October 15, 2005.
- Thomas Wang (March 2000). "Java Floating-Point Number Intricacies". September 2000.
- Specification. General Decimal Arithmetic: Encoding Strawman 4d, version 0.96. Retrieved on October 16, 2005. — a decimal floating point specification that includes negative zero
- Kittel, Charles, and Herbert Kroemer (1980). Thermal Physics. W. H. Freeman & Company. ISBN 0716710889.
[edit] Further reading
- Michael Ingrassia. Fortran 95 SIGN Change. Sun Developer Network. Retrieved on October 15, 2005. — the changes in the Fortran
SIGN
function in Fortran 95 to accommodate negative zero - JScript data types. MSDN JScript. Retrieved on October 16, 2005. — JScript's floating point type has negative zero by definition
- A look at the floating-point support of the Java virtual machine. Javaworld. Retrieved on October 16, 2005. — representation of negative zero in the Java virtual machine
- Bruce Dawson. "Comparing floating point numbers". — how to handle negative zero when comparing floating-point numbers
- John Walker. Minus Zero. UNIVAC Memories. Retrieved on October 17, 2005. — One's complement numbers on the UNIVAC® 1100 family computers.