|
Class: Math
Object
|
+--Math
- Package:
- stx:libjavascript
- Category:
- Languages-JavaScript-Framework
- Version:
- rev:
1.8
date: 2019/06/10 15:12:49
- user: cg
- file: Math.st directory: libjavascript
- module: stx stc-classLibrary: libjavascript
Simulates the javascript Math protocol
allows for
Math.sin(foo)
or
Math.atan2(a,b)
constants
-
E
-
Eulers constant, the base of the natural logarithm; approx 2.718
usage example(s):
JavaScriptParser
evaluate:'Math.E;'
|
-
LN10
-
natural logarithm of 10, approx 2.302
usage example(s):
JavaScriptParser
evaluate:'Math.LN10;'
|
-
LN2
-
natural logarithm of 2, approx 0.693
usage example(s):
JavaScriptParser
evaluate:'Math.LN2;'
|
-
LOG10E
-
base 10 logarithm of E; approx. 0.434
usage example(s):
JavaScriptParser
evaluate:'Math.LOG10E;'
|
-
LOG2E
-
base2 logarithm of E; approx. 1.442
usage example(s):
JavaScriptParser
evaluate:'Math.LOG2E;'
|
-
NEGATIVE_INFINITY
-
-inf
usage example(s):
JavaScriptParser evaluate:'Math.NEGATIVE_INFINITY;'
|
-
NaN
-
not a number
usage example(s):
JavaScriptParser evaluate:'Math.NaN;'
|
-
PI
-
pi; approx 3.14159
usage example(s):
JavaScriptParser
evaluate:'Math.PI;'
|
-
POSITIVE_INFINITY
-
+Inf
usage example(s):
JavaScriptParser evaluate:'Math.POSITIVE_INFINITY;'
|
-
SQRT1_2
-
square root of 1/2; approx 0.707
usage example(s):
JavaScriptParser
evaluate:'Math.SQRT1_2;'
|
-
SQRT2
-
square root of 2; approx. 1.414
usage example(s):
JavaScriptParser
evaluate:'Math.SQRT2;'
|
min & max
-
max
-
returns the largest of 0 to 6 args
usage example(s):
JavaScriptParser
evaluate:'Math.max();'
JavaScriptParser
evaluate:'Math.max(1);'
JavaScriptParser
evaluate:'Math.max(10,2);'
JavaScriptParser
evaluate:'Math.max(10,5,20);'
|
-
max: n1
-
returns the largest of 0 to 6 args
-
max: n1 _: n2
-
returns the largest of 0 to 6 args
-
max: n1 _: n2 _: n3
-
returns the largest of 0 to 6 args
-
max: n1 _: n2 _: n3 _: n4
-
returns the largest of 0 to 6 args
-
max: n1 _: n2 _: n3 _: n4 _: n5
-
returns the largest of 0 to 6 args
-
max: n1 _: n2 _: n3 _: n4 _: n5 _: n6
-
returns the largest of 0 to 6 args
-
min
-
returns the smallest of 0 to 6 args
usage example(s):
JavaScriptParser
evaluate:'Math.min();'
JavaScriptParser
evaluate:'Math.min(1);'
JavaScriptParser
evaluate:'Math.min(10,2);'
JavaScriptParser
evaluate:'Math.min(10,5,20);'
|
-
min: n1
-
returns the smallest of 0 to 6 args
-
min: n1 _: n2
-
returns the smallest of 0 to 6 args
-
min: n1 _: n2 _: n3
-
returns the smallest of 0 to 6 args
-
min: n1 _: n2 _: n3 _: n4
-
returns the smallest of 0 to 6 args
-
min: n1 _: n2 _: n3 _: n4 _: n5
-
returns the smallest of 0 to 6 args
-
min: n1 _: n2 _: n3 _: n4 _: n5 _: n6
-
returns the smallest of 0 to 6 args
misc math
-
abs: aNumber
-
returns the absolute value of a number
-
binco: n _: k
-
returns the binomialcoefficient C(n,k) (n over k, choose k from n)
-
ceil: aNumber
-
returns the smallest integer greater than or equal to aNumber
-
exp: aNumber
-
returns E^aNumber
-
fac: aNumber
-
returns the factorial of aNumber
-
floor: aNumber
-
returns the largest integer less than or equal to aNumber
-
gcd: a _: b
-
returns the greatest common divisor of a and b
-
ln: aNumber
-
returns the natural logarithm of aNumber.
-
log10: aNumber
-
returns the log base 10 of aNumber.
-
log: aNumber
-
returns the log base E of aNumber.
ATTENTION:
JS log is a base E log
ST log is a base 10 log (use ln for base E)
in JS, better use log10 to make things explicit.
-
pow: base _: exp
-
returns base^exp
-
random
-
returns a pseudo random number between 0 and 1
usage example(s):
JavaScriptParser
evaluate:'Math.random();'
|
-
random: min _: max
-
returns a pseudo random number between min and max
-
randomInteger: min _: max
-
returns a pseudo random number between min and max
-
round: aNumber
-
returns the value of aNumber rounded to the nearest integer
-
sqrt: aNumber
-
returns the square root of aNumber
queries
-
isUtilityClass
-
trigonometric
-
acos: aNumber
-
returns the arccosine (in radians) of a number
-
asin: aNumber
-
returns the arcsine (in radians) of a number
-
atan2: x _: y
-
returns the arctangent of the quotient of its arguments (in radians)
-
atan: aNumber
-
returns the arctangent (in radians) of a number
-
cos: aNumber
-
returns the cosine of a number (given in radians)
-
degreesToRadians: aNumber
-
converts degrees to radians
-
radiansToDegrees: aNumber
-
converts radians to degrees
-
sin: aNumber
-
returns the sine of a number (given in radians)
-
tan: aNumber
-
returns the tangent of a number (given in radians)
|