- Signed zero
Signed zero is zero with an associated sign. In ordinary arithmetic, −0 = +0 = 0. However, in computing, some number representations allow for the existence of two zeros, often denoted by −0 (negative zero) and +0 (positive zero). This occurs in the sign and magnitude and ones' complement signed number representations for integers, and in most floating point number representations. The number 0 is usually encoded as +0, but can be represented by either +0 or −0.
The IEEE 754 standard for floating point arithmetic (presently used by most computers and programming languages that support floating point numbers) requires both +0 and −0. The zeroes can be considered as a variant of the extended real number line such that 1/−0 = −∞ and 1/+0 = +∞, division by zero is only undefined for ±0/±0 and ±∞/±∞.
Negatively signed zero echoes the mathematical analysis concept of approaching 0 from below as a one-sided limit, which may be denoted by x → 0−, x → 0−, or x → ↑0. The notation "−0" may be used informally to denote a small negative number that has been rounded to zero. The concept of negative zero also has some theoretical applications in statistical mechanics and other disciplines.
It is claimed that the inclusion of signed zero in IEEE 754 makes it much easier to achieve numerical accuracy in some critical problems, in particular when computing with complex elementary functions. On the other hand, the concept of signed zero runs contrary to the general assumption made in most mathematical fields (and in most mathematics courses) that negative zero is the same thing as zero. Representations that allow negative zero can be a source of errors in programs, as software developers do not realize (or may forget) that, while the two zero representations behave as equal under numeric comparisons, they are different bit patterns and yield different results in some operations.
The widely used two's complement encoding does not allow a negative zero. In a 1+7-bit sign-and-magnitude representation for integers, negative zero is represented by the bit string 1000 0000. In an 8-bit one's complement representation, negative zero is represented by the bit string 1111 1111. In all three encodings, positive zero is represented by 0000 0000.
In IEEE 754 binary floating point numbers, zero values are represented by the biased exponent and significand both being zero. Negative zero has the sign bit set to one. One may obtain negative zero as the result of certain computations, for instance as the result of arithmetic underflow on a negative number, or
−1.0*0.0, or simply as
In IEEE 754 decimal floating point encoding a negative zero is represented by an exponent being any valid exponent in the range for the encoding, the true significand being zero, and the sign bit being one.
Properties and handling
The IEEE 754 floating point standard specifies the behavior of positive zero and negative zero under various operations. The outcome may depend on the current IEEE rounding mode settings.
Multiplication and division follow their usual rules for combining signs:
- (for x different from 0)
Addition and subtraction are handled specially if the values could cancel:
- (for any finite x, −0 when rounding toward negative)
Because of negative zero (and only because of it), the statements
z = -(x - y)and
z = (-x) - (-y), for floating-point variables
z, cannot be optimized to
z = y - x.
Some other special rules:
- (follows the sign rule for division)
- (for non-zero x, follows the sign rule for division)
- (Not a Number or interrupt for indeterminate form)
Division of a non-zero number by zero sets the divide by zero flag, and an operation producing a NaN sets the invalid operation flag. An exception handler is called if enabled for the corresponding flag.
According to the IEEE 754 standard, negative zero and positive zero should compare as equal with the usual (numerical) comparison operators, like the
==operators of C and Java. In those languages, special programming tricks may be needed to distinguish the two values:
- casting the number to an integer type, so as to compare the bit patterns;
- using the IEEE 754
copysign()function to copy the sign of the zero to some non-zero number;
- taking the reciprocal of the zero to obtain either 1/(+0) = +∞ or 1/(−0) = −∞.
However, some programming languages may provide alternative comparison operators that do distinguish the two zeros. This is the case, for example, of the equals method in Java's
Informally, one may use the notation "−0" for a negative value that was rounded to zero. This notation may be useful when a negative sign is significant; for example, when tabulating Celsius temperatures, where a negative sign means below freezing.
In statistical mechanics, one sometimes uses negative temperatures to describe systems with population inversion, which can be considered to have a temperature greater than positive infinity, because the coefficient of energy in the population distribution function is −1/Temperature. In this context, a temperature of −0 is a (theoretical) temperature larger than any other negative temperature, corresponding to the (theoretical) maximum conceivable extent of population inversion, the opposite extreme to +0.
- Line with two origins
- ^ 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.
- ^ William Kahan, Derivatives in the Complex z-plane, p10.
- ^ Cowlishaw, Mike (7 April 2009). "Decimal Arithmetic: Arithmetic operations – square-root". speleotrove.com (IBM Corporation). http://speleotrove.com/decimal/daops.html#refsqrt. Retrieved 7 December 2010.
- ^ 
- ^ Kittel, Charles and Herbert Kroemer (1980). Thermal Physics (2nd ed.). W. H. Freeman Company. p. 462. ISBN 0-7167-1088-9.
- "Floating point types". MSDN C# Language Specification. http://msdn.microsoft.com/library/en-us/csspec/html/vclrfcsharpspec_4_1_6.asp. Retrieved 15 October 2005.
- "Division operator". MSDN C# Language Specification. http://msdn.microsoft.com/library/en-us/csspec/html/vclrfcsharpspec_7_7_2.asp. Retrieved 15 October 2005.
- Thomas Wang (March 2000). Java Floating-Point Number Intricacies. September 2000. http://www.concentric.net/~Ttwang/tech/javafloat.htm.
- Mike Colishaw (28 July 2008). "Decimal Arithmetic Specification, version 1.68". http://speleotrove.com/decimal/decarith.html. Retrieved 2008-08-14. — a decimal floating point specification that includes negative zero
- Michael Ingrassia. "Fortran 95 SIGN Change". Sun Developer Network. http://developers.sun.com/prodtech/cc/articles/sign.html. Retrieved October 15, 2005. — the changes in the Fortran
SIGNfunction in Fortran 95 to accommodate negative zero
- "JScript data types". MSDN JScript. http://msdn.microsoft.com/library/en-us/script56/html/js56jscondatatype.asp. Retrieved 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. http://www.javaworld.com/javaworld/jw-10-1996/jw-10-hood.html. Retrieved October 16, 2005. — representation of negative zero in the Java virtual machine
- Bruce Dawson. Comparing floating point numbers. http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm. — how to handle negative zero when comparing floating-point numbers
- John Walker. "Minus Zero". UNIVAC Memories. http://www.fourmilab.ch/documents/univac/minuszero.html. Retrieved October 17, 2005. — One's complement numbers on the UNIVAC 1100 family computers.
Wikimedia Foundation. 2010.
Look at other dictionaries:
Zero copula — is a linguistic phenomenon whereby the subject is joined to the predicate without overt marking of this relationship (like the copula to be in English). One can distinguish languages that simply do not have a copula and languages that have a… … Wikipedia
Signed number representations — In computing, signed number representations are required to encode negative numbers in binary number systems. In mathematics, negative numbers in any base are represented by prefixing them with a − sign. However, in computer hardware, numbers are … Wikipedia
Signed graph — In the area of graph theory in mathematics, a signed graph is a graph in which each edge has a positive or negative sign.Formally, a signed graph Sigma; is a pair ( G , sigma;) that consists of a graph G = ( V , E ) and a sign mapping or… … Wikipedia
Signed distance function — In mathematics and applications, the signed distance function of a set S in a metric space determines how close a given point x is to the boundary of S , with that function having positive values at points x inside S , it decreases in value as x… … Wikipedia
Signed By Force — infobox record label parent = Semprini Records founded = 2007 distributor = genre = Alternative rock, Post hardcore, Punk rock, Hardcore punk country = Canada url = [http://www.signedbyforce.com/ signedbyforce.com] Signed By Force is a Montreal… … Wikipedia
Division by zero — This article is about the mathematical concept. For other uses, see Division by zero (disambiguation). The function y = 1/x. As x approaches 0 from the right, y approaches infinity. As x approaches 0 from the left, y approaches negative … Wikipedia
Run Level Zero — Infobox musical artist Name = Run Level Zero Img capt = From left to right : Ville Hising, Hans Åkerman (RLZ 2005) Background = group or band Origin = flagicon|Sweden Stockholm, Sweden Genre = electro industrial / aggrotech Years active = 1999… … Wikipedia
NX Zero — presentation in 2007. Background information Origin Brazil, São Paulo, SP Genres … Wikipedia
City of Oakland's Zero Waste Program — The City of Oakland, California, adopted a Zero Waste Strategic Plan in 2006, detailing a road map for the City to follow toward the implementation of a Zero Waste System by 2020. As stated in a City Resolution, introduced by then Mayor Jerry… … Wikipedia
Channel Zero (company) — Channel Zero Inc. Type Private company Industry Media Founded 2000 Headquarters … Wikipedia