scScript Math Package
The Math package in scScript, as well as most arithmetic operators,
simply fall through to equivalent libc functions and operators. scScript
Ints and Flts are C
language Int64 and double floats respectively.
Therefore, scScript is subject to the same numerical limitations as C
and provides the same NaN and Inf symbols and
semantics as C.
| Functions: | |
|---|---|
| Abs R = Math.Abs(F); |
Returns absolute value of F. (Will convert arg to Flt if Int.) Note: F, R, and M are Flt, X and S are Int. |
| Min R = Math.Min(F1, F2); |
Returns minimum of F1 and F2. (Will convert F1 and F2 to Flt if Int.) |
| Max R = Math.Max(F1, F2); |
Returns maximum of F1 and F2. (Will convert F1 and F2 to Flt if Int.) |
| FEq (Fuzzy/Float Eq) X = Math.FEq(F1, F2); X = Math.FEq(F1, F2, M); |
Returns 1 if F1 and F2 are very close (0 if not), within margin M. M (optional) is calculated internally as multiple of DBL_EPSILON, but if given M will be hard coded. M of 0 or 0.0 will take all fuzz out of comparison, same as ==. |
| Ln R = Math.Ln(F); |
Returns natural logarithm (base e) of F. |
| Log R = Math.Log(F); |
Returns common logarithm (base 10) of F. |
| Power R = Math.Power(F1, F2); |
Returns F1 raised to the power of F2. |
| Exp R = Math.Exp(F); |
Returns e raised to the power of F. |
| Sqrt R = Math.Sqrt(F); |
Returns square root of F. |
| Floor R = Math.Floor(F); R = Math.Floor(F, S); |
Returns the nearest flt not greater than F. S (Scale) power of 10, if given (Int or Flt) will apply before op. S of +3 means go to .001 precision, -3 means go to 1000's. |
| Ceiling R = Math.Ceiling(F); R = Math.Ceiling(F, S); |
Returns the nearest flt not less than F. S (Scale) power of 10, if given (Int or Flt) will apply before op. |
| Round R = Math.Round(F); R = Math.Round(F, S); |
Returns the nearest flt, rounding away from 0 in halfway cases. S (Scale) power of 10, if given (Int or Flt) will apply before op. |
| Cos R = Math.Cos(F); |
Returns cosine of F. Note: All trigonometric angles (F) are expressed in radians. |
| ACos F = Math.ACos(R); |
Returns arc cosine of R. |
| Cosh R = Math.Cosh(F); |
Returns hyperbolic cosine of F. |
| Sin R = Math.Sin(F); |
Returns sine of F. |
| ASin F = Math.ASin(R); |
Returns arc sine of R. |
| Sinh R = Math.Sinh(F); |
Returns hyperbolic sine of F. |
| Tan R = Math.Tan(F); |
Returns tangent of F. |
| ATan F = Math.ATan(R); |
Returns arc tangent of R. |
| Tanh R = Math.Tanh(F); |
Returns hyperbolic tangent of F. |
| Defs: (Constants courtesy of Libc!) | |
|---|---|
| #Pi | 3.1415926535897931 (Flts are generally not accurate beyond 16 places.) |
| #E (Ok, looks weird, #e then!) | 2.7182818284590451 |
| #LogE (#Loge?) | 0.4342944819032518 |
| #Ln2 | 0.6931471805599453 |
| #Ln10 | 2.3025850929940459 |
| #Sqrt2 | 1.4142135623730951 |
| #Int_Max | 9,223,372,036,854,775,807 (INT_MAX in C) (2^63 - 1) |
| #Int_Min | -9,223,372,036,854,775,808 (INT_MIN in C) (- 2^63) |
| #Flt_Max | Approx. 1.7e+308 (DBL_Max in C) |
| #Flt_Min | Approx. -1.7e+308 (-DBL_Max in C) |
| #Flt_Small | Approx. 2.22e-308 (DBL_Min in C) |
| #Flt_Epsilon | Approx. 2.22e-16 or 0x01p-52 (DBL_EPSILON in C) |
| #NaN | Defined as (0.0/0.0) but prints out as -nan from libc. Importantly, (#Nan != #Nan) but (#Nan === #Nan) !!! |
| #Pos_Inf | Defined as (1.0/0.0). Prints out as inf from libc. |
| #Neg_Inf | Defined as (-1.0/0.0). Prints out as -inf from libc. |