Skip to content

Commit 8927120

Browse files
committed
[css-values-4][editorial] Pull IEEE stuff into a subsection.
1 parent 11b6b73 commit 8927120

1 file changed

Lines changed: 128 additions & 87 deletions

File tree

css-values-4/Overview.bs

Lines changed: 128 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ Default Highlight: css
1717
Include Can I Use Panels: yes
1818
</pre>
1919
<pre class='link-defaults'>
20-
spec: css2; type: property; text: border-collapse
20+
spec: css2;
21+
type: property; text: border-collapse
2122
spec: css-color-4; type: value; text: currentcolor
2223
spec: css-color-5; type: type; text: <color>
2324
spec: css-color-5; type:type; text: <absolute-color-function>
@@ -1157,7 +1158,7 @@ URL Processing Model</h4>
11571158
[=request/client=] is |environmentSettings|,
11581159
and whose [=request/referrer=] is |environmentSettings|'s [=API base URL=].
11591160

1160-
5. Apply any <dfn>URL request modifier steps</dfn> that apply to this request.
1161+
5. Apply any <dfn export>URL request modifier steps</dfn> that apply to this request.
11611162

11621163
Note: This specification does not define any URL request modification steps,
11631164
but other specs may do so.
@@ -3983,7 +3984,7 @@ Numeric Constants: ''e'', ''pi''</h3>
39833984
Degenerate Numeric Constants: ''infinity'', <nobr>''-infinity''</nobr>, ''NaN''</h4>
39843985

39853986
When a [=calculation=] or a subtree of a [=calculation=]
3986-
becomes infinite or NaN,
3987+
becomes [=infinite=] or [=NaN=],
39873988
representing it with a numeric value is no longer possible.
39883989
To aid in serialization of these degenerate values,
39893990
the additional math constants
@@ -4197,90 +4198,6 @@ Type Checking</h3>
41974198
If it can't [=CSSNumericValue/match=] any of these,
41984199
the [=math function=] is invalid.
41994200

4200-
Division by zero is possible,
4201-
which introduces certain complications.
4202-
[=Math functions=] follow IEEE-754 semantics for these operations:
4203-
4204-
* Dividing a positive value by zero produces +∞.
4205-
* Dividing a negative value by zero produces −∞.
4206-
* Adding or subtracting ±∞ to anything produces the appropriate infinity,
4207-
unless a following rule would define it as producing NaN.
4208-
* Multiplying any value by ±∞ produces the appropriate infinity,
4209-
unless a following rule would define it as producing NaN.
4210-
* Dividing any value by ±∞ produces zero,
4211-
unless a following rule would define it as producing NaN.
4212-
* Dividing zero by zero,
4213-
dividing ±∞ by ±∞,
4214-
multiplying 0 by ±∞,
4215-
adding +∞ to −∞
4216-
(or the equivalent subtractions)
4217-
produces NaN.
4218-
* Any operation with at least one NaN argument produces NaN.
4219-
4220-
Additionally,
4221-
IEEE-754 introduces the concept of a "signed zero",
4222-
which is specifically positive or negative,
4223-
and which must be tracked within a calculation
4224-
and between nested calculations:
4225-
4226-
* Negative zero
4227-
(0⁻)
4228-
can be produced by a multiplication or division that produces zero
4229-
with exactly one negative argument
4230-
(such as ''-5 * 0'' or ''1 / (-infinity)''),
4231-
or by certain argument combinations in the other [=math functions=].
4232-
4233-
Note: Note that negative zeros don't escape a [=math function=];
4234-
as detailed below,
4235-
they're "censored" away into an "unsigned" zero.
4236-
* ''0⁻ + 0⁻''
4237-
or ''0⁻ - 0''
4238-
produces 0⁻.
4239-
All other additions or subtractions that would produce a zero
4240-
produce 0⁺.
4241-
* Multiplying or dividing 0⁻ with a positive number
4242-
(including 0⁺)
4243-
produces a negative result
4244-
(either 0⁻ or −∞),
4245-
while multiplying or dividing 0⁻ with a negative number
4246-
produces a positive result.
4247-
4248-
(In other words,
4249-
multiplying or dividing with 0⁻
4250-
follows standard sign rules.)
4251-
* When comparing 0⁺ and 0⁻,
4252-
0⁻ is less than 0⁺.
4253-
For example, ''min(0⁺, 0⁻)'' must produce 0⁻,
4254-
''max(0⁺, 0⁻)'' must produce 0⁺,
4255-
and ''clamp(0⁺, 0⁻, 1)'' must produce 0⁺.
4256-
* Unless otherwise specified,
4257-
any other operation that produces a zero
4258-
produces positive zero (0⁺).
4259-
4260-
If a <dfn export>top-level calculation</dfn>
4261-
(a [=math function=] not nested inside of another [=math function=])
4262-
would produce a value whose numeric part is NaN,
4263-
it instead act as though the numeric part is 0.
4264-
If a [=top-level calculation=]
4265-
would produce a value whose numeric part is 0⁻ or 0⁺,
4266-
it instead acts as though the numeric part is the standard "unsigned" zero.
4267-
4268-
<div class=example>
4269-
For example, ''calc(-5 * 0)'' produces an unsigned zero--
4270-
the calculation resolves to 0⁻,
4271-
but as it's a [=top-level calculation=],
4272-
it's then censored to an unsigned zero.
4273-
4274-
On the other hand, ''calc(1 / calc(-5 * 0))'' produces −∞,
4275-
same as ''calc(1 / (-5 * 0))''--
4276-
the inner calc resolves to 0⁻,
4277-
and as it's not a [=top-level calculation=],
4278-
it passes it up unchanged to the outer calc to produce −∞.
4279-
If it was censored into an unsigned zero,
4280-
it would instead produce +∞.
4281-
</div>
4282-
4283-
42844201
Note: Algebraic simplifications do not affect the validity of a [=math function=] or its resolved type.
42854202
For example, ''calc(5px - 5px + 10s)'' and ''calc(0 * 5px + 10s)'' are both invalid
42864203
due to the attempt to add a length and a time.
@@ -4323,6 +4240,130 @@ Type Checking</h3>
43234240
might become valid in Quirks Mode
43244241
(and have its result interpreted as a ''px'' length).
43254242

4243+
<h4 id='calc-ieee'>
4244+
Infinities, NaN, and Signed Zero</h4>
4245+
4246+
[=Math functions=] follow IEEE-754 semantics,
4247+
which means they recognize the concepts of
4248+
positive and negative zero,
4249+
positive and negative infinity,
4250+
and NaN (not a number).
4251+
4252+
However, these concepts are only retained within a [=calculation tree=];
4253+
if a <dfn export>top-level calculation</dfn>
4254+
(a [=math function=] not nested directly inside of another [=math function=])
4255+
would result in one of these special values,
4256+
they're instead "censored" into a standard representable value,
4257+
as defined below.
4258+
4259+
<dfn lt="signed zero|positive zero|negative zero" for=CSS export>Signed zeros</dfn>
4260+
(indicated here as 0⁺ or 0⁻)
4261+
can not be written directly in CSS;
4262+
''0'', ''+0'' and ''-0'' all produce the standard "unsigned" zero,
4263+
which is considered positive (0⁺)
4264+
for the purposes of these rules.
4265+
4266+
[=Signed zeroes=] are produced in the following ways:
4267+
4268+
* Negative zero
4269+
(0⁻)
4270+
can be produced by a multiplication or division that produces zero
4271+
with exactly one negative argument
4272+
(such as ''-5 * 0'' or ''1 / -infinity'').
4273+
* ''0⁻ + 0⁻''
4274+
or ''0⁻ - 0⁺''
4275+
produces 0⁻.
4276+
All other additions or subtractions that would produce a zero
4277+
produce 0⁺.
4278+
* Multiplying or dividing 0⁻ with a positive number
4279+
(including 0⁺)
4280+
produces a negative result
4281+
(either 0⁻ or −∞),
4282+
while multiplying or dividing 0⁻ with a negative number
4283+
produces a positive result.
4284+
4285+
(In other words,
4286+
multiplying or dividing with 0⁻
4287+
follows standard sign rules.)
4288+
* When comparing 0⁺ and 0⁻,
4289+
0⁻ is less than 0⁺.
4290+
For example, ''min(0⁺, 0⁻)'' must produce 0⁻,
4291+
''max(0⁺, 0⁻)'' must produce 0⁺,
4292+
and ''clamp(0⁺, 0⁻, 1)'' must produce 0⁺.
4293+
* Certain argument combinations in [=math functions=]
4294+
are defined to produce 0⁻
4295+
(for example, ''round(-1, infinity)'').
4296+
All other operations that produce a zero
4297+
produce positive zero (0⁺).
4298+
4299+
[=Signed zeroes=] do not escape a [=top-level calculation=];
4300+
they're censored into the "unsigned" zero.
4301+
4302+
<dfn lt="infinity|infinite|positive infinity|negative infinity" for=CSS export>Infinities</dfn>
4303+
(indicated here as +∞ or −∞)
4304+
can be written directly
4305+
using the [[#calc-error-constants|math constants]]
4306+
''infinity'' and ''-infinity'',
4307+
or produced as a result of some calculations:
4308+
4309+
* Dividing a value by zero produces either +∞ or −∞,
4310+
according to the standard sign rules.
4311+
* Adding or subtracting ±∞ to anything produces the appropriate infinity.
4312+
* Multiplying any value by ±∞ produces the appropriate infinity.
4313+
* Dividing any value by ±∞ produces zero.
4314+
* Certain argument combinations in [=math functions=]
4315+
are defined to produce [=infinities=]
4316+
(for example, ''pow(0, -1)'' produces +∞).
4317+
4318+
Note: The rules for producing [=NaN=], below,
4319+
supersede the above rules for producing [=infinities=].
4320+
4321+
[=Infinities=] do not escape a [=top-level calculation=];
4322+
they're clamped to the minimum or maximum value allowed in the context,
4323+
as defined in [[#calc-range]].
4324+
4325+
<dfn for=CSS export>NaN</dfn>
4326+
(short for "not a number")
4327+
is the result of certain operations
4328+
that don't have a well-defined value.
4329+
It can be written directly
4330+
using the [[#calc-error-constants|math constants]]
4331+
''NaN'',
4332+
or produced as a result of some calculations:
4333+
4334+
* Dividing zero by zero,
4335+
dividing ±∞ by ±∞,
4336+
multiplying 0 by ±∞,
4337+
adding +∞ to −∞,
4338+
or subtracting two infinities of the same sign
4339+
produces NaN.
4340+
4341+
These rules override any other result,
4342+
if there's a conflict.
4343+
For example, ''0 / 0'' is NaN, not +∞.
4344+
* Certain argument combinations in [=math functions=]
4345+
are defined to produce [=NaN=]
4346+
(for example, ''asin(2)'' produces NaN).
4347+
* Any operation with at least one NaN argument produces NaN.
4348+
4349+
[=NaN=] does not escape a [=top-level calculation=];
4350+
it's censored into a zero value
4351+
4352+
<div class=example>
4353+
For example, ''calc(-5 * 0)'' produces an unsigned zero--
4354+
the calculation resolves to 0⁻,
4355+
but as it's a [=top-level calculation=],
4356+
it's then censored to an unsigned zero.
4357+
4358+
On the other hand, ''calc(1 / calc(-5 * 0))'' produces −∞,
4359+
same as ''calc(1 / (-5 * 0))''--
4360+
the inner calc resolves to 0⁻,
4361+
and as it's not a [=top-level calculation=],
4362+
it passes it up unchanged to the outer calc to produce −∞.
4363+
If it was censored into an unsigned zero,
4364+
it would instead produce +∞.
4365+
</div>
4366+
43264367

43274368
<h3 id='calc-internal'>
43284369
Internal Representation</h3>

0 commit comments

Comments
 (0)