@@ -2632,6 +2632,10 @@ Argument Ranges</h4>
2632
2632
the result is NaN.
2633
2633
(See [[#calc-type-checking]] for details on how [=math functions=] handle NaN.)
2634
2634
2635
+ In ''sin(A)'' or ''tan(A)'' ,
2636
+ if A is 0⁻,
2637
+ the result is 0⁻.
2638
+
2635
2639
In ''tan(A)'' , if A is one of the asymptote values
2636
2640
(such as ''90deg'' , ''270deg'' , etc),
2637
2641
the result must be +∞ for ''90deg'' and all values a multiple of ''360deg'' from that
@@ -2650,22 +2654,78 @@ Argument Ranges</h4>
2650
2654
if A is less than -1 or greater than 1,
2651
2655
the result is NaN.
2652
2656
2657
+ In ''acos(A)'' ,
2658
+ if A is exactly 1,
2659
+ the result is 0.
2660
+
2661
+ In ''asin(A)'' or ''atan(A)'' ,
2662
+ if A is 0⁻,
2663
+ the result is 0⁻.
2664
+
2653
2665
In ''atan(A)'' ,
2654
2666
if A is +∞,
2655
2667
the result is ''90deg'' ;
2656
2668
if A is −∞,
2657
2669
the result is ''-90deg'' .
2658
2670
2659
- In ''atan2(A, B)'' ,
2660
- if A and B are both zero,
2661
- the result is ''0deg'' .
2662
- If either or both [=calculations=] are infinite,
2663
- the function must return an angle
2664
- as if the infinite value was replaced by ''1'' (for +∞) or ''-1'' (for −∞)
2665
- and the finite value was replaced by ''0'' :
2666
- ''atan2(finite, ∞)'' must return ''0deg'' , as if it were ''atan2(0, 1)'' ;
2667
- ''atan2(∞, ∞)'' must return ''45deg'' , as if it were ''atan2(1, 1)'' ;
2668
- and so on around the circle.
2671
+ In ''atan2(Y, X)'' ,
2672
+ the following table gives the results for all unusual argument combinations:
2673
+
2674
+ <table class=data>
2675
+ <thead>
2676
+ <tr><td style="border:none" colspan=2><th colspan=6> X
2677
+ <tr><td style="border:none" colspan=2><th> −∞ <th> -finite <th> 0⁻ <th> 0⁺ <th> +finite <th> +∞
2678
+ </thead>
2679
+ <tr>
2680
+ <th rowspan=6 style="border-right:1px solid silver"> Y
2681
+ <th style="border-right: black 2px solid"> −∞
2682
+ <td> -135deg
2683
+ <td> -90deg
2684
+ <td> -90deg
2685
+ <td> -90deg
2686
+ <td> -90deg
2687
+ <td> -45deg
2688
+ <tr>
2689
+ <th> -finite
2690
+ <td> -180deg
2691
+ <td> (normal)
2692
+ <td> -90deg
2693
+ <td> -90deg
2694
+ <td> (normal)
2695
+ <td> 0⁻deg
2696
+ <tr>
2697
+ <th> 0⁻
2698
+ <td> -180deg
2699
+ <td> -180deg
2700
+ <td> -180deg
2701
+ <td> 0⁻deg
2702
+ <td> 0⁻deg
2703
+ <td> 0⁻deg
2704
+ <tr>
2705
+ <th> 0⁺
2706
+ <td> 180deg
2707
+ <td> 180deg
2708
+ <td> 180deg
2709
+ <td> 0⁺deg
2710
+ <td> 0⁺deg
2711
+ <td> 0⁺deg
2712
+ <tr>
2713
+ <th> +finite
2714
+ <td> 180deg
2715
+ <td> (normal)
2716
+ <td> 90deg
2717
+ <td> 90deg
2718
+ <td> (normal)
2719
+ <td> 0⁺deg
2720
+ <tr>
2721
+ <th> +∞
2722
+ <td> 135deg
2723
+ <td> 90deg
2724
+ <td> 90deg
2725
+ <td> 90deg
2726
+ <td> 90deg
2727
+ <td> 45deg
2728
+ </table>
2669
2729
2670
2730
Note: All of these behaviors are intended to match the "standard" definitions of these functions
2671
2731
as implemented by most programming languages,
@@ -2839,77 +2899,57 @@ Exponential Functions: ''pow()'', ''sqrt()'', ''hypot()''</h3>
2839
2899
Argument Ranges</h4>
2840
2900
2841
2901
In ''pow(A, B)'' ,
2842
- if A is negative,
2902
+ if A is negative and finite,
2903
+ and B is finite,
2843
2904
B must be an integer,
2844
2905
or else the result is NaN.
2845
2906
2846
- If A and B are both 0,
2847
- the result is 1.
2848
- If A is 0⁺ and B is negative,
2849
- the result is +∞;
2850
- if A is 0⁻ and B is negative,
2851
- the result is −∞.
2852
-
2853
- If A or B is infinite,
2907
+ If A or B are infinite or 0,
2854
2908
the following tables give the results:
2855
2909
2856
- <table class=data>
2910
+ <table class=data style="table-layout:fixed" >
2857
2911
<thead>
2858
- <tr><th scope=col colspan=3> A is +∞
2859
- <tr>
2860
- <th> B is < 0
2861
- <th> B is 0
2862
- <th> B is > 0
2912
+ <tr><td>
2913
+ <th> A is −∞
2914
+ <th> A is 0⁻
2915
+ <th> A is 0⁺
2916
+ <th> A is +∞
2863
2917
</thead>
2864
2918
<tr>
2865
- <td> result is 0⁺
2866
- <td> result is 1
2867
- <td> result is +∞
2868
- </table>
2869
-
2870
- <table class=data>
2871
- <thead>
2872
- <tr><th scope=col colspan=3> A is −∞
2873
- <tr>
2874
- <th> B is < 0
2875
- <th> B is 0
2876
- <th> B is > 0
2877
- </thead>
2919
+ <th> B is −finite
2920
+ <td> 0⁻ if B is an odd integer, 0⁺ otherwise
2921
+ <td> −∞ if B is an odd integer, +∞ otherwise
2922
+ <td> +∞
2923
+ <td> 0⁺
2878
2924
<tr>
2879
- <td> result is 0⁻ if B is an odd integer, 0⁺ otherwise
2880
- <td> result is 1
2881
- <td> result is −∞ if B is an odd integer, +∞ otherwise
2925
+ <th> B is 0
2926
+ <td colspan=4> always 1
2927
+ <tr>
2928
+ <th> B is +finite
2929
+ <td> −∞ if B is an odd integer, +∞ otherwise
2930
+ <td> 0⁻ if B is an odd integer, 0⁺ otherwise
2931
+ <td> 0⁺
2932
+ <td> +∞
2882
2933
</table>
2883
2934
2884
2935
<table class=data>
2885
2936
<thead>
2886
- <tr><th scope=col colspan=5> B is +∞
2887
- <tr>
2937
+ <tr><td>
2888
2938
<th> A is < -1
2889
2939
<th> A is -1
2890
2940
<th> -1 < A < 1
2891
2941
<th> A is 1
2892
2942
<th> A is > 1
2893
2943
</thead>
2894
2944
<tr>
2945
+ <th> B is +∞
2895
2946
<td> result is +∞
2896
2947
<td> result is NaN
2897
2948
<td> result is 0⁺
2898
2949
<td> result is NaN
2899
2950
<td> result is +∞
2900
- </table>
2901
-
2902
- <table class=data>
2903
- <thead>
2904
- <tr><th scope=col colspan=5> B is −∞
2905
- <tr>
2906
- <th> A is < -1
2907
- <th> A is -1
2908
- <th> -1 < A < 1
2909
- <th> A is 1
2910
- <th> A is > 1
2911
- </thead>
2912
2951
<tr>
2952
+ <th> B is −∞
2913
2953
<td> result is 0⁺
2914
2954
<td> result is NaN
2915
2955
<td> result is +∞
@@ -2920,6 +2960,8 @@ Argument Ranges</h4>
2920
2960
In ''sqrt(A)'' ,
2921
2961
if A is +∞,
2922
2962
the result is +∞.
2963
+ If A is 0⁻,
2964
+ the result is 0⁻.
2923
2965
If A is less than 0,
2924
2966
the result is NaN.
2925
2967
@@ -2933,6 +2975,12 @@ Argument Ranges</h4>
2933
2975
as implemented by most programming languages,
2934
2976
in particular as implemented in JS.
2935
2977
2978
+ Issue: Per JS, hypot(∞, NaN) yields ∞, and pow(NaN, 0) yields 1.
2979
+ This violates the standard calculation rules of NaNs being fully infective.
2980
+ Do we want to carry that behavior over as well?
2981
+ Or maybe specifically undefine it,
2982
+ since it's just error behavior?
2983
+
2936
2984
2937
2985
<h3 id='calc-syntax'>
2938
2986
Syntax</h3>
@@ -3114,7 +3162,7 @@ Type Checking</h3>
3114
3162
and between nested calculations:
3115
3163
3116
3164
* Negative zero
3117
- (0<sup> − </sup> )
3165
+ (0⁻ )
3118
3166
can be produced literally by negating a zero
3119
3167
(''-0'' ),
3120
3168
or by a multiplication or division that produces zero
@@ -3131,41 +3179,41 @@ Type Checking</h3>
3131
3179
they're "censored" away into an "unsigned" zero.
3132
3180
* ''-0 + -0''
3133
3181
or ''-0 - 0''
3134
- produces 0<sup> − </sup> .
3182
+ produces 0⁻ .
3135
3183
All other additions or subtractions that would produce a zero
3136
- produce 0<sup> + </sup> .
3137
- * Multiplying or dividing 0<sup> − </sup> with a positive number
3138
- (including 0<sup> + </sup> )
3184
+ produce 0⁺ .
3185
+ * Multiplying or dividing 0⁻ with a positive number
3186
+ (including 0⁺ )
3139
3187
produces a negative result
3140
- (either 0<sup> − </sup> or −∞),
3141
- while multiplying or dividing 0<sup> − </sup> with a negative number
3188
+ (either 0⁻ or −∞),
3189
+ while multiplying or dividing 0⁻ with a negative number
3142
3190
produces a positive result.
3143
3191
3144
3192
(In other words,
3145
- multiplying or dividing with 0<sup> − </sup>
3193
+ multiplying or dividing with 0⁻
3146
3194
follows standard sign rules.)
3147
- * When comparing 0<sup> + </sup> and 0<sup> − </sup> ,
3148
- 0<sup> − </sup> is less than 0<sup> + </sup> .
3149
- For example, ''min(0, -0)'' must produce 0<sup> − </sup> ,
3150
- ''max(0, -0)'' must produce 0<sup> + </sup> ,
3151
- and ''clamp(0, -0, 1)'' must produce 0<sup> + </sup> .
3195
+ * When comparing 0⁺ and 0⁻ ,
3196
+ 0⁻ is less than 0⁺ .
3197
+ For example, ''min(0, -0)'' must produce 0⁻ ,
3198
+ ''max(0, -0)'' must produce 0⁺ ,
3199
+ and ''clamp(0, -0, 1)'' must produce 0⁺ .
3152
3200
3153
3201
If a <dfn export>top-level calculation</dfn>
3154
3202
(a [=math function=] not nested inside of another [=math function=] )
3155
3203
would produce a NaN,
3156
3204
it instead produces +∞.
3157
- If a [=top-level calculation=] would produce 0<sup> − </sup> ,
3205
+ If a [=top-level calculation=] would produce 0⁻ ,
3158
3206
it instead produces the standard "unsigned" zero.
3159
3207
3160
3208
<div class=example>
3161
3209
For example, ''calc(-5 * 0)'' produces an unsigned zero--
3162
- the calculation resolves to 0<sup> − </sup> ,
3210
+ the calculation resolves to 0⁻ ,
3163
3211
but as it's a [=top-level calculation=] ,
3164
3212
it's then censored to an unsigned zero.
3165
3213
3166
3214
On the other hand, ''calc(1 / calc(-5 * 0))'' produces −∞,
3167
3215
same as ''calc(1 / (-5 * 0))'' --
3168
- the inner calc resolves to 0<sup> − </sup> ,
3216
+ the inner calc resolves to 0⁻ ,
3169
3217
and as it's not a [=top-level calculation=] ,
3170
3218
it passes it up unchanged to the outer calc to produce −∞.
3171
3219
If it was censored into an unsigned zero,
0 commit comments