Share to: share facebook share twitter share wa share telegram print page

Signed zero

Signed zero is zero with an associated sign. In ordinary arithmetic, the number 0 does not have a sign, so that −0, +0 and 0 are equivalent. However, in computing, some number representations allow for the existence of two zeros, often denoted by −0 (negative zero) and +0 (positive zero), regarded as equal by the numerical comparison operations but with possible different behaviors in particular operations. This occurs in the sign-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 still be represented by +0, −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. Real arithmetic with signed zeros can be considered a variant of the extended real number line such that 1/−0 = −∞ and 1/+0 = +∞; division is undefined only 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 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,[1] in particular when computing with complex elementary functions.[2] On the other hand, the concept of signed zero runs contrary to the usual assumption made in mathematics that negative zero is the same value as zero. Representations that allow negative zero can be a source of errors in programs, if software developers do not take into account that while the two zero representations behave as equal under numeric comparisons, they yield different results in some operations.

Representations

Binary integer formats can use various encodings. In the widely used two's complement encoding, zero is unsigned. In a 1+7-bit sign-and-magnitude representation for integers, negative zero is represented by the bit string 10000000. In an 8-bit ones' complement representation, negative zero is represented by the bit string 11111111. In all these three encodings, positive or unsigned zero is represented by 00000000. However, the latter two encodings (with a signed zero) are uncommon for integer formats. The most common formats with a signed zero are floating-point formats (IEEE 754 formats or similar), described below.

Negative zero by IEEE 754 representation in binary32

In IEEE 754 binary floating-point formats, 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 (other results may also be possible), or −1.0×0.0, or simply as −0.0.

In IEEE 754 decimal floating-point formats, a negative zero is represented by an exponent being any valid exponent in the range for the format, 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.

Notation

In systems that include both signed and unsigned zeros, the notation and is sometimes used for signed zeros.

Arithmetic

Addition and multiplication are commutative, but there are some special rules that have to be followed, which mean the usual mathematical rules for algebraic simplification may not apply. The sign below shows the obtained floating-point results (it is not the usual equality operator).

The usual rule for signs is always followed when multiplying or dividing:

  • (for different from ±∞)
  • (for different from 0)

There are special rules for adding or subtracting signed zero:

  • (for different from 0)
  • (for any finite , −0 when rounding toward negative)

Because of negative zero (and also when the rounding mode is upward or downward), the expressions −(xy) and (−x) − (−y), for floating-point variables x and y, cannot be replaced by yx. However (−0) + x can be replaced by x with rounding to nearest (except when x can be a signaling NaN).

Some other special rules:

  • [3]
  • (follows the sign rule for division)
  • (for non-zero , 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.

Comparisons

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:

  • Type punning the number to an integer type, so as to look at the sign bit in the bit pattern;
  • using the ISO C copysign() function (IEEE 754 copySign operation) to copy the sign of the zero to some non-zero number;
  • using the ISO C signbit() macro (IEEE 754 isSignMinus operation) that returns whether the sign bit of a number is set;
  • taking the reciprocal of the zero to obtain either 1/(+0) = +∞ or 1/(−0) = −∞ (if the division by zero exception is not trapped).

Note: Casting to integral type will not always work, especially on two's complement systems.

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 Double wrapper class.[4]

In rounded values such as temperatures

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

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.[5]

See also

References

  1. ^ 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.
  2. ^ William Kahan, Derivatives in the Complex z-plane, p. 10.
  3. ^ Cowlishaw, Mike (7 April 2009). "Decimal Arithmetic: Arithmetic operations – square-root". speleotrove.com (IBM Corporation). Retrieved 7 December 2010.
  4. ^ "Double". Java™ Platform, Standard Edition 6 API Specification. Oracle Help Center. Archived from the original on Aug 4, 2009.
  5. ^ Kittel, Charles and Herbert Kroemer (1980). Thermal Physics (2nd ed.). W. H. Freeman and Company. p. 462. ISBN 0-7167-1088-9.

Further reading

Read other articles:

Bridge across the Waiwhakaiho River in New Plymouth, New Zealand Te Rewa Rewa BridgeTe Rewa Rewa Bridge with Mount Taranaki in the backgroundCoordinates39°02′16″S 174°06′44″E / 39.03777°S 174.11229°E / -39.03777; 174.11229 (Te Rewa Rewa Bridge)Carriespedestrians, cyclistsCrossesWaiwhakaiho RiverLocaleNew Plymouth, Taranaki, New ZealandOfficial nameTe Rewa Rewa BridgeCharacteristicsDesignsteel archMaterialSteel, concrete deckTotal length70 mWidth2.5 mHe…

Katiu Coordenadas: 16° 25' S 144° 22' O Geografia física País Polinésia Francesa Arquipélago Tuamotu Gambier Área 10  km² Geografia humana População 285 Densidade 28,5  hab./km² Katiu é uma das ilhas do arquipélago de Tuamotu-Gambier, pertencente ao Taiti.[1] Referências ↑ Atoll names Este artigo sobre Geografia da Polinésia Francesa é um esboço. Você pode ajudar a Wikipédia expandindo-o. vdeArquipélagos de Tuamotu-Gambier - Polinésia FrancesaTuamotuGambi…

KlisoeraКлисура Dorp in Bulgarije Situering Oblast Sofia Gemeente Samokov Coördinaten 42° 20′ NB, 23° 22′ OL Algemeen Oppervlakte 30,91 km² Inwoners (31 december 2019) 199 Hoogte 1100 m Overig Postcode 2026 Netnummer 07124 Kenteken СО Portaal    Bulgarije Klisoera (Bulgaars: Клисура) is een dorp in het westen van Bulgarije. Zij is gelegen in de gemeente Samokov in de oblast Sofia. Het dorp ligt 15 km van Samokov, 25 km van Doepnitsa en 40 km ten zuiden v…

SK GroupKantor pusat SK Group, Januari 2014.Nama asli에스케이 주식회사JenisPublikKode emitenKRX: 034730IndustriKonglomeratDidirikan8 April 1953; 70 tahun lalu (1953-04-08)KantorpusatSeoul, Korea SelatanTokohkunciChey Tae-won, Chairman & CEOCho Dae-sik, Chairman Dewan SUPEX (kepala de facto)[1]ProdukEnergi & Kimia, Telekomunikasi, Perdagangan & Jasa, SemikonduktorPendapatan US$213,6 milyar (2018)Laba bersih US$23,8 milyar (2018)Total aset US$257,9 milyar (2018)Kar…

У Вікіпедії є статті про інших людей із прізвищем Кадиров. Кадиров Рамзан Ахматовиччеч. КъадиргӀеран Ахьмадан кӀант Рамзан Кадиров Рамзан Ахматович Прапор Голова Чеченської Республіки з 5 березня 2011 Попередник: посаду поновлено. Фактично — «президент» Чечні Прапор …

Psahno Tin AlitheiaΨάχνω Την ΑλήθειαСингл Єлена Папарізу з альбому Giro Apo T' OneiroВипущений 20 травня 2010Формат радіо-сингл, завантаження через ІнтернетЗаписаний 2010Жанр dance-popКомпозитор Пер Ліден, Ніклас Олафссон, Тоні Маврідіс, Янніс ДоксасТривалість 3:09Лейбл Sony Music Greece/RCAПродюсер Don-K (Ні…

Shire of Wiluna Local Government Area van Australië Locatie van Shire of Wiluna in West-Australië Situering Staat West-Australië Hoofdplaats Wiluna Coördinaten 26°35'42ZB, 120°13'30OL Algemene informatie Oppervlakte 182.155,8 km² Inwoners 535 (2021)[1] Overig Wards geen Website (en) Shire of Wiluna Portaal    Australië Shire of Wiluna is een lokaal bestuursgebied (LGA) in de regio Mid West in West-Australië. Geschiedenis Op 29 oktober 1909 werd het Wiluna Road District…

1989 single by Edoardo Bennato and Gianna Nannini, Susan Ferrer (Spanish Version)Un'estate italianaTo be number one (English version)Un verano italiano (Spanish version)Single by Edoardo Bennato and Gianna NanniniSusan Ferrer (Spanish Version)B-sideKaraoke versionReleased9 December 1989Recorded1989GenrePop rockLength4:07LabelWarner Bros.SugarVirginComposer(s)Giorgio MoroderLyricist(s)Gianna NanniniEdoardo Bennato (Italian)Tom Whitlock (English)Susan Ferrer (Spanish)Producer(s)Giorgio MoroderGian…

Ferrocarril de AntioquiaLugarÁrea abastecida AntioquiaDescripciónTipo TrenCaracterísticas técnicasLongitud red Puerto Berrío - Limón 117km Santiago - Medellín 71KmElectrificación noElevación .Propietario Antioquia 1880 - 1962 Ferrocarriles Nacionales de Colombia 1962Esquema ¿? Puerto Berrío La Malena Calera Cristalina Sabaletas Cabañas Palestina Virginias Pavas Caracolí San José del Nus Gallinazo Providencia Guacharacas San Jorge Sofía Cisneros o La Quiebra Limón (Boca del …

جزء من سلسلة مقالات سياسة السودانالسودان الدستور الدستور حقوق الإنسان السلطة التنفيذية الرئيس عبد الفتاح البرهان نواب الرئيس محمد حمدان دقلو مجلس الوزراء السلطة التشريعية المجلس التشريعي مجلس الولايات المجلس الوطني السلطة القضائية القضاء المحكمة الدستورية المحكمة العل…

Historic house in Arkansas, United States United States historic placeWhite-Baucum HouseU.S. National Register of Historic Places Location in ArkansasShow map of ArkansasLocation in United StatesShow map of the United StatesLocation201 S. Izard St., Little Rock, ArkansasCoordinates34°44′53″N 92°16′46″W / 34.74806°N 92.27944°W / 34.74806; -92.27944Arealess than one acreBuilt1869 (1869)Architectural styleItalianateNRHP reference No.80000785&#…

يفتقر محتوى هذه المقالة إلى الاستشهاد بمصادر. فضلاً، ساهم في تطوير هذه المقالة من خلال إضافة مصادر موثوق بها. أي معلومات غير موثقة يمكن التشكيك بها وإزالتها. (مارس 2016) كأس أفريقيا للأندية البطلة 1974 كأس البطولة الأول (من 1964 إلى 1977) تفاصيل البطولة المنظم الاتحاد الأفريقي لكرة ال…

South Korean handball team South KoreaInformationAssociationKorea Handball FederationColours 1st 2nd ResultsIHF U-20 World ChampionshipAppearances20 (First in 1981)Best result Champions : (2014) Last updated on Unknown. The South Korea women's junior national handball team is the national under-19 handball team of South Korea. Controlled by the Korea Handball Federation that is an affiliate of the International Handball Federation IHF as well as a member of the Asian Handball Federation AHF…

Communauté de communes de la Région de Guebwiller Administration Pays France Région Grand Est Département Haut-Rhin Forme Communauté de communes Siège Guebwiller Communes 19 Président Marcello Rotolo (PS) Date de création 29 novembre 2000 Code SIREN 246800569 Démographie Population 38 069 hab. (2019) Densité 201 hab./km2 Géographie Superficie 189,40 km2 Localisation Localisation de la C.C.R.G. dans le Haut-Rhin Liens Site web http://www.cc-guebwiller.fr/ Fiche Bana…

It's a Beautiful Day Its a Beautiful Day 1972Datos generalesOrigen San FranciscoInformación artísticaGénero(s) Rock psicodélicoPeríodo de actividad 1967-1974 [editar datos en Wikidata] It's a Beatiful Day es una banda norteamericana formada en San Francisco, California, en 1967 por la vocalista Pattie Santos junto con el violinista David LaFlamme, que había sido solista en la Orquesta Sinfónica de la Utah, anteriormente había formado parte de la banda Orkustra, e inus…

Kabupaten Musi Rawas UtaraKabupatenTranskripsi bahasa daerah • Abjad Jawiموسي راواس اوتاراJembatan Air Rawas, di Rupit LambangMotto: Berselang serundinganPetaKabupaten Musi Rawas UtaraPetaTampilkan peta SumatraKabupaten Musi Rawas UtaraKabupaten Musi Rawas Utara (Indonesia)Tampilkan peta IndonesiaKoordinat: 2°44′07″S 102°54′05″E / 2.7352°S 102.9015°E / -2.7352; 102.9015Negara IndonesiaProvinsiSumatera SelatanTanggal be…

Senegalese footballer (born 1992) Sadio Mané Mané with Al Nassr in 2023Personal informationFull name Sadio Mané[1]Date of birth (1992-04-10) 10 April 1992 (age 31)[2]Place of birth Bambali, SenegalHeight 1.74 m (5 ft 9 in)[3]Position(s) Winger, forward[4]Team informationCurrent team Al NassrNumber 10Youth career2009–2011 Génération FootSenior career*Years Team Apps (Gls)2011 Metz B 12 (2)2012 Metz 22 (2)2012–2014 Red Bull Salzburg 63 (…

Kristina AkheevaKristina Akheeva (2013)Lahir1 November 1986 (umur 37)Khabarovsk, RusiaKebangsaanAustralia (Etnis : Rusia)PekerjaanModel, aktrisTahun aktif2012–SekarangSitus webwww.kristina-akheeva.com Kristina Akheeva (kelahiran 1 November 1986) adalah seorang aktris dan model Australia. Ia membuat debut Bollywoodnya pada film 2013 Yamla Pagla Deewana 2. Disusul dengan film Telegu Galipatam yang dirilis pada 2014. Kehidupan awal Akheeva lahir di Khabarovsk, Rusia dari ibu Rusia …

Political corruption Concepts Anti-corruption Bribery Cronyism Economics of corruption Electoral fraud Elite capture Influence peddling Kleptocracy Mafia state Nepotism Slush fund Simony Corruption by country Africa Angola Botswana Cameroon Chad Comoros Congo Egypt Equatorial Guinea Eritrea Ethiopia Ghana Guinea-Bissau Kenya Liberia Mauritius Morocco Nigeria Senegal Sierra Leone Somalia South Africa South Sudan Sudan Tanzania Tunisia Uganda Zambia Zimbabwe Asia Afghanistan Armenia Azerbaijan Bah…

  關於其他同名車站,請見「池上車站」 池上站站舍(2021年4月)日语名称池上 – いけがみ – Ikegami车站概览位置 日本東京都大田區池上六丁目3番10號地理坐标35°34′19.02″N 139°42′10.04″E / 35.5719500°N 139.7027889°E / 35.5719500; 139.7027889车站构造站体类型地面車站站台2面2線历史启用日期1922年(大正11年)10月6日上下車人次統計年…

Kembali kehalaman sebelumnya

Lokasi Pengunjung: 3.22.61.128