Namespace: joker.math
v1.0Contents
Summary
Provides floating-point mathematical functions, IEEE-754 helpers, and numeric constants.
Index
- abs
- ceil
- copy-sign
- cos
- cube-root
- dim
- e
- exp
- exp-2
- exp-minus-1
- floor
- hypot
- inf
- inf?
- ln-of-10
- ln-of-2
- log
- log-10
- log-10-of-e
- log-2
- log-2-of-e
- log-binary
- log-plus-1
- max-double
- modf
- nan
- nan?
- next-after
- phi
- pi
- pow
- pow-10
- precision
- round
- round-to-even
- set-precision
- sign-bit
- sin
- smallest-nonzero-double
- sqrt
- sqrt-of-2
- sqrt-of-e
- sqrt-of-phi
- sqrt-of-pi
- trunc
Constants
Constants are variables with :const true in their metadata. Joker currently does not recognize them as special; as such, it allows redefining them or their values.-
e
Double v1.0e
-
ln-of-10
Double v1.0Natural logarithm of 10
-
ln-of-2
Double v1.0Natural logarithm of 2
-
log-10-of-e
Double v1.0Base-10 logarithm of e
-
log-2-of-e
Double v1.0Base-2 logarithm of e
-
max-double
Double v1.0Largest finite value representable by Double
-
phi
Double v1.0Phi
-
pi
Double v1.0pi
-
smallest-nonzero-double
Double v1.0Smallest positive, non-zero value representable by Double
-
sqrt-of-2
Double v1.0Square root of 2
-
sqrt-of-e
Double v1.0Square root of e
-
sqrt-of-phi
Double v1.0Square root of phi
-
sqrt-of-pi
Double v1.0Square root of pi
Variables
-
(None.)
Functions, Macros, and Special Forms
-
abs
Function v1.0(abs x)(abs ^Number x)Returns the absolute value of x.
show types -
ceil
Function v1.0(ceil x)(ceil ^Number x)Returns the least integer value greater than or equal to x.
show types -
copy-sign
Function v1.0(copy-sign x y)(copy-sign ^Number x ^Number y)Returns value with the magnitude of x and the sign of y.
show types -
cos
Function v1.0(cos x)(cos ^Number x)Returns the cosine of the radian argument x.
show types -
cube-root
Function v1.0(cube-root x)(cube-root ^Number x)Returns the cube root of x.
show types -
dim
Function v1.0(dim x y)(dim ^Number x ^Number y)Returns the maximum of x-y and 0.
show types -
exp
Function v1.0(exp x)(exp ^Number x)Returns e**x, the base-e exponential of x.
show types -
exp-2
Function v1.0(exp-2 x)(exp-2 ^Number x)Returns 2**x, the base-2 exponential of x.
show types -
exp-minus-1
Function v1.0(exp-minus-1 x)(exp-minus-1 ^Number x)Returns e**x - 1, the base-e exponential of x minus 1.
show types
This is more accurate than (- (exp x) 1.) when x is near zero. -
floor
Function v1.0(floor x)(floor ^Number x)Returns the greatest integer value less than or equal to x.
show types -
hypot
Function v1.0(hypot p q)(hypot ^Number p ^Number q)Returns Sqrt(p*p + q*q), taking care to avoid unnecessary overflow and underflow.
show types -
inf
Function v1.0(inf sign)(inf ^Int sign)Returns positive infinity if sign >= 0, negative infinity if sign < 0.
show types -
inf?
Function v1.0(inf? x sign)(inf? ^Number x ^Int sign)Returns whether x is an infinity.
show types
If sign > 0, returns whether x is positive infinity; if < 0, whether negative infinity; if == 0, whether either infinity. -
log
Function v1.0(log x)(log ^Number x)Returns the natural logarithm of x.
show types -
log-10
Function v1.0(log-10 x)(log-10 ^Number x)Returns the decimal logarithm of x.
show types -
log-2
Function v1.0(log-2 x)(log-2 ^Number x)Returns the binary logarithm of x.
show types -
log-binary
Function v1.0(log-binary x)(log-binary ^Number x)Returns the binary exponent of x.
show types -
log-plus-1
Function v1.0(log-plus-1 x)(log-plus-1 ^Number x)Returns the natural logarithm of 1 plus x.
show types
This is more accurate than (log (+ 1 x)) when x is near zero. -
modf
Function v1.0(modf x)(modf ^Number x)Returns a vector with the integer and fractional floating-point numbers that sum to x.
show types
Both values have the same sign as x. -
nan
Function v1.0(nan)Returns an IEEE 754 "not-a-number" value.
-
nan?
Function v1.0(nan? x)(nan? ^Number x)Returns whether x is an IEEE 754 "not-a-number" value.
show types -
next-after
Function v1.0(next-after x y)(next-after ^Number x ^Number y)Returns the next representable Double value after x towards y.
show types -
pow
Function v1.0(pow x y)(pow ^Number x ^Number y)Returns x**y, the base-x exponential of y.
show types -
pow-10
Function v1.0(pow-10 x)(pow-10 ^Int x)Returns 10**x, the base-10 exponential of x.
show types -
precision
Function v1.0(precision f)(precision ^Number f)Returns the precision of a Number.
show types
The precision excludes any sign or exponent. For a BigInt, it's the
number of bits needed to represent the number; for a BigFloat, Int,
or Double, it's the number of bits available in that instance or
type. E.g. (precision 1) returns either 31 or 63, depending on
whether the Joker executable is 32-bit or 64-bit (for integers);
(precision 1.0) returns 53 (as Double is always a float64); and
(precision 1.0M) returns 53 as well, though prepending or appending
enough 0 digits will result in a BigFloat with more precision
reported.
If f is not a supported Number type (such as Ratio), a panic
results. -
round
Function v1.0(round x)(round ^Number x)Returns the integer nearest to x, rounding half away from zero.
show types -
round-to-even
Function v1.0(round-to-even x)(round-to-even ^Number x)Returns the integer nearest to x, rounding ties to the nearest even integer.
show types -
set-precision
Function v1.0(set-precision prec f)(set-precision ^Number prec ^BigFloat f)Returns a copy of a BigFloat with the specified precision.
show types
Calls Go's math/big.(*Float)SetPrec(prec) on a copy of f. prec must
evaluate to a non-negative integer. Returns the resulting BigFloat. -
sign-bit
Function v1.0(sign-bit x)(sign-bit ^Number x)Returns whether x is negative or negative zero.
show types -
sin
Function v1.0(sin x)(sin ^Number x)Returns the sine of the radian argument x.
show types -
sqrt
Function v1.0(sqrt x)(sqrt ^Number x)Returns the square root of x.
show types -
trunc
Function v1.0(trunc x)(trunc ^Number x)Returns the integer value of x, rounded toward zero.
show types