@@ -1831,7 +1831,7 @@ Type Checking</h4>
18311831
18321832 Division by zero is possible,
18331833 which introduces certain complications.
1834- [=Math functions=] follow simplified versions of IEEE-754 semantics for these operations:
1834+ [=Math functions=] follow IEEE-754 semantics for these operations:
18351835
18361836 * Dividing a positive value by zero produces +∞.
18371837 * Dividing a negative value by zero produces −∞.
@@ -1849,14 +1849,70 @@ Type Checking</h4>
18491849 produces NaN.
18501850 * Any operation with at least one NaN argument produces NaN.
18511851
1852- If a <dfn export>top-level calculations</dfn>
1853- (an argument to ''min()'' , ''max()'' , or ''clamp()'' ,
1854- or a ''calc()'' that's not nested directly inside of another [=math function=] )
1852+ Additionally,
1853+ IEEE-754 introduces the concept of "negative zero",
1854+ which must be tracked within a calculation
1855+ and between nested calculations:
1856+
1857+ * Negative zero
1858+ (0<sup> -</sup> )
1859+ can be produced literally by negating a zero
1860+ (''-0'' ),
1861+ or by a multiplication or division that produces zero
1862+ with exactly one negative argument
1863+ (such as ''-5 * 0'' or ''1 / (-1 / 0)'' ).
1864+
1865+ Note: Note that,
1866+ outside of [=math functions=] ,
1867+ ''-0'' just produces a "standard" zero,
1868+ identical to ''0'' --
1869+ CSS as a whole doesn't recognize the concept of signed zeros.
1870+ Negative zeros also don't escape a [=math function=] ;
1871+ as detailed below,
1872+ they're "censored" away into an "unsigned" zero.
1873+ * ''-0 + -0''
1874+ or ''-0 - 0''
1875+ produces 0<sup> -</sup> .
1876+ All other additions or subtractions that would produce a zero
1877+ produce 0<sup> +</sup> .
1878+ * Multiplying or dividing 0<sup> -</sup> with a positive number
1879+ (including 0<sup> +</sup> )
1880+ produces a negative result
1881+ (either 0<sup> -</sup> or −∞),
1882+ while multiplying or dividing 0<sup> -</sup> with a negative number
1883+ produces a positive result.
1884+
1885+ (In other words,
1886+ multiplying or dividing with 0<sup> -</sup>
1887+ follows standard sign rules.)
1888+ * When comparing 0<sup> +</sup> and 0<sup> -</sup> ,
1889+ 0<sup> -</sup> is less than 0<sup> +</sup> .
1890+ For example, ''min(0, -0)'' must produce 0<sup> -</sup> ,
1891+ ''max(0, -0)'' must produce 0<sup> +</sup> ,
1892+ and ''clamp(0, -0, 1)'' must produce 0<sup> +</sup> .
1893+
1894+ If a <dfn export>top-level calculation</dfn>
1895+ (a [=math function=] not nested inside of another [=math function=] )
18551896 would produce a NaN,
18561897 it instead produces +∞.
1857- Other calculations
1858- (such as a ''calc()'' nested directly within a [=math function=] )
1859- can produce NaN as normal.
1898+ If a [=top-level calculation=] would produce 0<sup> -</sup> ,
1899+ it instead produces the standard "unsigned" zero.
1900+
1901+ <div class=example>
1902+ For example, ''calc(-5 * 0)'' produces an unsigned zero--
1903+ the calculation resolves to 0<sup> -</sup> ,
1904+ but as it's a [=top-level calculation=] ,
1905+ it's then censored to an unsigned zero.
1906+
1907+ On the other hand, ''calc(1 / calc(-5 * 0))'' produces −∞,
1908+ same as ''calc(1 / (-5 * 0))'' --
1909+ the inner calc resolves to 0<sup> -</sup> ,
1910+ and as it's not a [=top-level calculation=] ,
1911+ it passes it up unchanged to the outer calc to produce −∞.
1912+ If it was censored into an unsigned zero,
1913+ it would instead produce +∞.
1914+ </div>
1915+
18601916
18611917 Note: Algebraic simplifications do not affect the validity of a [=math function=] or its resolved type.
18621918 For example, ''calc(5px - 5px + 10s)'' and ''calc(0 * 5px + 10s)'' are both invalid
0 commit comments