−0 (number)

−0 (number)

−0 is the representation of negative zero or minus zero, a number that, in computing, exists 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 equal to, and represented as, zero.

In common usage, −0 may be used to denote a negative number rounded to zero, or a number approaching zero from the negative direction. In statistical mechanics, certain systems in a state of population inversion may be considered to have an absolute temperature of −0, the hottest possible absolute temperature (see negative temperature).

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.

Negative zero cannot be distinguished from positive zero with conventional two's complement encoding, which is the most common representation of signed binary integers.

Properties and handling

In programming languages such as C, C#, C++, Java, and Javascript, 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 under default (numerical) comparison. Thus a simple comparison is not sufficient to test whether a number is negative zero.

Ways of testing include
*using the copysign() function, which is defined by IEEE 754 to copy the sign of the zero, to some non-zero number
*dividing the number into a positive number—the resulting Infinity will reflect the sign of the zero.
** frac{k}{+0} = +infty (for positive k)
** frac{k}{-0} = -infty (for positive k)For example, in Javascript:function isNegativeZero(x) { return x = 0 && 1/x < 0; }isNegativeZero(-0.0); // Result: trueisNegativeZero( 0.0); // Result: falseNote that in other languages, this may require disabling any trap that might occur on division by zero.
*in Java, using the equals method in the Double class, which treats negative zero as distinct from positive zero; for example:Double negativeZero = new Double(-0.0);negativeZero.equals(-0.0); // Result: truenegativeZero.equals( 0.0); // Result: false
*in C, using a non-portable technique that relies on the local hardware representation, e.g., *(int *)&var = 0x80000000 (where var is encoded in IEEE 754 single precision).

Other operations involving negative zero:
* frac{-0}{x} = -0,! (for positive x)
* frac{-0}{x} = +0,! (for negative x)
* frac{+0}{x} = -0,! (for negative x)
* frac{-0}{+infty} = -0,!
* frac{-0}{-infty} = +0,!
* frac{+0}{-infty} = -0,!
* (-0) cdot (-0) = +0,!
* (-0) - (+0) = -0,!
* (-0) - (-0) = 0,!
* (+0) + (-0) = 0,!
* (-0) + (-0) = -0,!
* left| x ight| cdot (-0) = -0,!
* x + (-0) = x,!

Use of an integer representation that contains negative zero can be a source of errors in programs when software developers do not realize that, while the two zero representations compare equal, they are treated differently by some operations.

Use of a floating-point representation that contains negative zero may be necessary to achieve numerical accuracy in some critical problems. [William Kahan. "Branch Cuts for Complex Elementary Functions, or Much Ado About Nothing's Sign Bit", in "The State of the Art in Numerical Analysis" (eds. Iserles and Powell), Clarendon Press, Oxford, 1987.]

cientific uses

In meteorology, −0 can be used to indicate a temperature which is below zero, especially for the Celsius scale where below zero indicates freezing. It is often important for statistical reasons, when it 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.

Notes

References

*
*
*
* &mdash; a "decimal" floating point specification that includes negative zero
*cite book|first=Charles|last=Kittel|coauthors=and Herbert Kroemer|title=Thermal Physics|publisher=W. H. Freeman & Company|year=1980|id=ISBN 0716710889

Further reading

* &mdash; the changes in the Fortran SIGN function in Fortran 95 to accommodate negative zero
* &mdash; JScript's floating point type has negative zero by definition
* &mdash; representation of negative zero in the Java virtual machine
* &mdash; how to handle negative zero when comparing floating-point numbers
* &mdash; One's complement numbers on the UNIVAC 1100 family computers.


Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Look at other dictionaries:

  • Number Six (The Prisoner) — Number Six is the central fictional character in the 1960s television series The Prisoner, played by Patrick McGoohan. In the AMC remake, the character is played by Jim Caviezel, renamed Six . In several episodes, his attempts to escape his… …   Wikipedia

  • Number Nine Visual Technology — Corporation was a manufacturer of video graphics chips and cards from 1982 to 1999. Number Nine developed the first 128 bit graphics processor (the Imagine 128), as well as the first 256 color and 16.8 million color cards.[1] The name of the… …   Wikipedia

  • Number 96 (TV series) — Number 96 Title card from a 1975 episode of Number 96. Where the cliff hanger resolution that followed this shot at the start of the episode took place in one of the building s flats, the shot of the building would zoom in on that flat as the… …   Wikipedia

  • Number 1 (Goldfrapp song) — Number 1 Single by Goldfrapp from the album Supernature B side …   Wikipedia

  • Number 1 (Tinchy Stryder song) — Number 1 Single by Tinchy Stryder featuring N Dubz from the album Catch 22 Against All Odds B side Stuck on …   Wikipedia

  • Number One — or number one abbreviated #1, No 1 is used in a variety of meanings: Numerical * 1 (number) Music * #1 , an album by Fischerspooner * Konono N°1, a musical group from Kinshasa, Democratic Republic of the Congo * No.1 , an album by BoA * #1 , a… …   Wikipedia

  • Number Ones (Janet Jackson album) — Number Ones / The Best Greatest hits album by Janet Jackson Released November 17, 2009 (see …   Wikipedia

  • Number Two (The Prisoner) — Number Two was the title of the chief administrator[1] of The Village in the 1967 68 British television series The Prisoner. More than 17 different actors appeared as holders of the office during the 17 episode series (some episodes featured more …   Wikipedia

  • Number Six (Battlestar Galactica) — Number Six Battlestar Galactica character Promotional still of Number Six in season four First appearance …   Wikipedia

  • Number 2 (Austin Powers) — Number 2 Austin Powers character First appearance Austin Powers: International Man of Mystery …   Wikipedia

  • Number Ones: Up Close and Personal — World Tour Official poster for the tour Tour by Janet Jackson Associated album Number Ones …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”