You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/jsbignum.texi
+14-27Lines changed: 14 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -102,18 +102,12 @@ The operator is looked up with the following name:
102
102
@item /
103
103
@code{Symbol.operatorDiv}
104
104
105
-
@item / (math mode)
106
-
@code{Symbol.operatorMathDiv}
107
-
108
105
@item %
109
106
@code{Symbol.operatorMod}
110
107
111
108
@item % (math mode)
112
109
@code{Symbol.operatorMathMod}
113
110
114
-
@item ^ (math mode)
115
-
@code{Symbol.operatorMathPow}
116
-
117
111
@item **
118
112
@code{Symbol.operatorPow}
119
113
@@ -266,29 +260,24 @@ The @code{+} operator also accepts strings as input and behaves like
266
260
standard Javascript in this case.
267
261
268
262
The binary operator @code{%} returns the truncated remainder of the
269
-
division.
263
+
division. When the result is an Integer type, a dividend of zero yields a
264
+
RangeError exception.
270
265
271
266
The binary operator @code{%} in math mode returns the Euclidian
272
267
remainder of the division i.e. it is always positive.
273
268
274
269
The binary operator @code{/} returns a float.
275
270
276
271
The binary operator @code{/} in math mode returns a float if one of
277
-
the operands is float. Otherwise, @code{BigInt[Symbol.operatorMathDiv]} is
278
-
invoked (and returns a fraction for example).
279
-
280
-
When the result is an Integer type, a dividend of zero yields a
281
-
RangeError exception.
272
+
the operands is float. Otherwise, @code{BigInt[Symbol.operatorDiv]} is
273
+
invoked.
282
274
283
-
The returned type of @code{a**b} or @code{a^b} (math mode) is
284
-
Float if @math{a} or @math{b} are Float. If @math{a} and @math{b} are
285
-
integers:
275
+
The returned type of @code{a**b} is Float if @math{a} or @math{b}
276
+
are Float. If @math{a} and @math{b} are integers:
286
277
@itemize
287
-
@item@math{a=0} and @math{b<0} generates a RangeError exception
278
+
@item@math{b<0} returns a Float in bigint mode. In math mode, @code{BigInt[Symbol.operatorPow]} is invoked.
288
279
289
-
@item@math{|a|\geq2} and @math{b<0} returns a Float in bigint mode. In math mode, @code{BigInt[Symbol.operatorMathPow]} is invoked (and returns a fraction for example)
290
-
291
-
@item otherwise an integer is returned.
280
+
@item@math{b>=0} returns an integer.
292
281
@end itemize
293
282
294
283
The unary @code{-} and unary @code{+} return the same type as their
@@ -798,21 +787,23 @@ is returned, no rounding is performed.
798
787
A new @emph{math mode} is enabled with the @code{"usemath"}
799
788
directive. @code{"usebigint"} is implied in math mode. With this
800
789
mode, writing mathematical expressions is more intuitive, exact
801
-
results (fractions) can be computed for all operators and floating
790
+
results (e.g. fractions) can be computed for all operators and floating
802
791
point literals have the @code{BigFloat} type by default.
803
792
804
793
It propagates the same way as the @emph{strict mode}. In
805
794
this mode:
806
795
807
796
@itemize
808
797
809
-
@item The @code{^} operator is a similar to the power operator (@code{**}), except that @code{a^b} invokes @code{BigInt[Symbol.operatorMathPow]} if @math{a} and @math{b} are integers and @math{|a|\geq2} and @math{b<0}.
798
+
@item The @code{^} operator is a similar to the power operator (@code{**}).
810
799
811
800
@item The power operator (both @code{^} and @code{**}) grammar is modified so that @code{-2^2} is allowed and yields @code{-4}.
812
801
813
802
@item The logical xor operator is still available with the @code{^^} operator.
814
803
815
-
@item The division operator invokes @code{BigInt[Symbol.operatorMathDiv]} in case both operands are integers.
804
+
@item The division operator invokes @code{BigInt[Symbol.operatorDiv]} in case both operands are integers.
805
+
806
+
@item The power operator invokes @code{BigInt[Symbol.operatorPow]} in case both operands are integers and the exponent is strictly negative.
816
807
817
808
@item The modulo operator returns the Euclidian remainder (always positive) instead of the truncated remainder.
818
809
@@ -824,19 +815,15 @@ this mode:
824
815
825
816
@subsection@code{Symbol} constructor
826
817
827
-
The following global symbols are added for the operator overloading:
818
+
The following global symbol is added for the operator overloading:
828
819
@table@code
829
-
@item operatorMathDiv
830
820
@item operatorMathMod
831
-
@item operatorMathPow
832
821
@end table
833
822
834
823
@section Remaining issues
835
824
836
825
@enumerate
837
826
838
-
@item New functions (e.g. @code{Math.div} and @code{Math.mod}) could be added to be able to call the normal division and modulo operators when in math mode.
839
-
840
827
@item A new floating point literal suffix could be added for @code{Number} literals.
0 commit comments