Math

The Math class provides static properties and functions useful in arithmetic.

Static Properties

A value of 3.141592653589793115997963468544185161590576171875

print Sparkle's Math's pi

A value of 6.28318530717958623199592693708837032318115234375

print Sparkle's Math's tau

A value of 2.718281828459045090795598298427648842334747314453125

print Sparkle's Math's e

A value of 1.6180339887498949025257388711906969547271728515625

print Sparkle's Math's phi

A value of 9007199254740991

print Sparkle's Math's maximum_safe_integer

A value of -9007199254740991

print Sparkle's Math's minimum_safe_integer

Static Functions

Returns the sign of a value, -1 if negative, 0 if zero, and 1 if positive.

let value be -3
let sign be call Sparkle's Math's sign with just value

if sign is equal to 0 do
  print "{value} is zero"
otherwise if sign is equal to 1 do
  print "{value} is positive"
otherwise
  print "{value} is negative"

Returns the square root of a value.

let value be 4
let square_root be call Sparkle's Math's square_root with just value

print "The square root of {value} is {square_root}"

Returns the natural logarithm of a value.

let value be 4
let logarithm be call Sparkle's Math's logarithm with just value

print "The natural logarithm of {value} is {logarithm}"

Returns the exponential of a value.

let value be 4
let exponential be call Sparkle's Math's exponential with just value

print "The exponential of {value} is {exponential}"

Trigonometric Functions

Converts degrees to radians.

let degrees be 90
let radians be call Sparkle's Math's degrees_to_radians with just degrees

print "{degrees} degrees is {radians} radians"

Converts radians to degrees.

let radians be Sparkle's Math's pi divided by 2
let degrees be call Sparkle's Math's radians_to_degrees with just radians

print "{radians} radians is {degrees} degrees"

Normalizes an angle in radians to the range [0, 2π).

let angle be Sparkle's Math's pi times 12.3
let normalized_angle be call Sparkle's Math's normalize_angle with just angle

print "The normalized angle of {angle} is {normalized_angle}"

Calculates the sine of an angle in radians.

let x be call Sparkle's Math's sine with just 1.23

Calculates the cosine of an angle in radians.

let x be call Sparkle's Math's cosine with just 1.23

Calculates the tangent of an angle in radians.

let x be call Sparkle's Math's tangent with just 1.23

Calculates the arc sine of a value.

let x be call Sparkle's Math's arc_sine with just 0.5

Calculates the arc cosine of a value.

let x be call Sparkle's Math's arc_cosine with just 0.5

Calculates the arc tangent of a value.

let x be call Sparkle's Math's arc_tangent with just 0.5