Skip to content

Commit 8e3fb63

Browse files
committed
[css-values-4] Add abs() and sign().
1 parent 57591b1 commit 8e3fb63

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

css-values-4/Overview.bs

+37
Original file line numberDiff line numberDiff line change
@@ -3059,6 +3059,41 @@ Argument Ranges</h4>
30593059
</div>
30603060

30613061

3062+
<h3 id='calc-signs'>
3063+
Sign-Related Functions: ''abs()'', ''sign()''</h3>
3064+
3065+
The sign-related functions--
3066+
''abs()'' and ''sign()''--
3067+
compute various functions related to the sign of their argument.
3068+
3069+
The <dfn lt="abs()">abs(A)</dfn> function
3070+
contains one [=calculation=] A,
3071+
and returns the absolute value of A
3072+
(if A is non-negative, just A;
3073+
if A is negative, ''-1 * A'')
3074+
as the same [=CSSNumericValue/type=] as the input.
3075+
3076+
The <dfn lt="sign()">sign(A)</dfn> function
3077+
contains one [=calculation=] A,
3078+
and returns -1 if A is negative,
3079+
+1 if A is positive,
3080+
0⁺ if A is 0⁺,
3081+
and 0⁻ if A is 0⁻.
3082+
3083+
Note: Both of these functions operate on the fully simplified/resolved form of their arguments,
3084+
which may give unintuitive results at first glance.
3085+
In particular, an expression like ''10%''
3086+
an expression like ''10%'' might be positive <em>or</em> negative once it's resolved,
3087+
depending on what value it's resolved against.
3088+
For example, in 'background-position' positive percentages
3089+
resolve to a negative length,
3090+
and vice versa,
3091+
if the background image is larger than the background area.
3092+
Thus ''sign(10%)'' might return ''1'' <em>or</em> ''-1'',
3093+
depending on how the percentage is resolved!
3094+
(Or even ''0'', if it's resolved against a zero length.)
3095+
3096+
30623097
<h3 id='calc-syntax'>
30633098
Syntax</h3>
30643099

@@ -3081,6 +3116,8 @@ Syntax</h3>
30813116
<<hypot()>> = hypot( <<calc-sum>># )
30823117
<<log()>> = log( <<calc-sum>>, <<calc-sum>>? )
30833118
<<exp()>> = exp( <<calc-sum>> )
3119+
<<abs()>> = abs( <<calc-sum>> )
3120+
<<sign()>> = sign( <<calc-sum>> )
30843121
<dfn>&lt;calc-sum></dfn> = <<calc-product>> [ [ '+' | '-' ] <<calc-product>> ]*
30853122
<dfn>&lt;calc-product></dfn> = <<calc-value>> [ [ '*' | '/' ] <<calc-value>> ]*
30863123
<dfn>&lt;calc-value></dfn> = <<number>> | <<dimension>> | <<percentage>> | ( <<calc-sum>> )

0 commit comments

Comments
 (0)