Skip to content

Class Math

Kristian Virtanen edited this page Oct 28, 2024 · 6 revisions

Description:

The Math class provides a collection of mathematical functions and constants, including basic arithmetic operations, trigonometric functions, logarithms, rounding, and random number generation. It also includes error handling via the LastError property, which stores the most recent error message if an operation fails.

Properties

Math.Pi

  • Description: Returns the value of Pi (π).
  • Example: 3.141592653589793
  • Differences from orig. SB: none.

Math.LastError

  • Description: Stores the last error message, if any operation fails, including a timestamp in yyyy-MM-dd HH:mm:ss format.
  • Example: "2024-10-16 14:30:00: Invalid parameter passed for GetRandomString: '0'. Positive integer expected."
  • Differences from orig. SB: New feature, orig. SB did not have this.

Methods

Math.Abs(number)

  • Description: Returns the absolute value of a number.
  • Parameters:
    • number: The number whose absolute value is to be determined.
  • Returns: The absolute value of the number.
  • Differences from orig. SB: none.

Math.Ceiling(number)

  • Description: Rounds a number up to the nearest integer.
  • Parameters:
    • number: The number to round up.
  • Returns: The smallest integer greater than or equal to the number.
  • Differences from orig. SB: none.

Math.Floor(number)

  • Description: Rounds a number down to the nearest integer.
  • Parameters:
    • number: The number to round down.
  • Returns: The largest integer less than or equal to the number.
  • Differences from orig. SB: none.

Math.NaturalLog(number)

  • Description: Returns the natural logarithm (base e) of a number.
  • Parameters:
    • number: The number to calculate the natural logarithm of.
  • Returns: The natural logarithm of the number.
  • Differences from orig. SB: none.

Math.Log(number)

  • Description: Returns the base-10 logarithm of a number.
  • Parameters:
    • number: The number to calculate the base-10 logarithm of.
  • Returns: The base-10 logarithm of the number.
  • Differences from orig. SB: none.

Math.Cos(number), Math.Sin(number), Math.Tan(number)

  • Description: Returns the cosine, sine, or tangent of a specified angle in radians.
  • Parameters:
    • angle: The angle in radians.
  • Returns: The cosine, sine, or tangent of the angle.
  • Differences from orig. SB: none.

Math.ArcSin(number), Math.ArcCos(number), Math.ArcTan(number)

  • Description: Returns the arcsine, arccosine, or arctangent of a specified value.
  • Parameters:
    • number: The value whose arcsine, arccosine, or arctangent is to be found.
  • Returns: The arcsine, arccosine, or arctangent in radians.
  • Differences from orig. SB: none.

Math.GetDegrees(angle)

  • Description: Converts the specified angle from radians to degrees.
  • Parameters:
    • angle: The angle in radians.
  • Returns: The equivalent angle in degrees.
  • Differences from orig. SB: none.

Math.GetRadians(angle)

  • Description: Converts the specified angle from degrees to radians.
  • Parameters:
    • angle: The angle in degrees.
  • Returns: The equivalent angle in radians.
  • Differences from orig. SB: none.

Math.SquareRoot(number)

  • Description: Returns the square root of the specified number.
  • Parameters:
    • number: The number whose square root is to be found.
  • Returns: The square root of the number.
  • Differences from orig. SB: none.

Math.Power(baseNumber, exponent)

  • Description: Returns the result of raising a base number to a specified exponent.
  • Parameters:
    • baseNumber: The base number.
    • exponent: The exponent to raise the base to.
  • Returns: The base number raised to the exponent.
  • Differences from orig. SB: none.

Math.Round(number)

  • Description: Rounds a number to the nearest integer.
  • Parameters:
    • number: The number to round.
  • Returns: The nearest integer to the number.
  • Differences from orig. SB: none.

Math.Max(number1, number2), Math.Min(number1, number2)

  • Description: Returns the greater or smaller of two numbers.
  • Parameters:
    • number1: The first number.
    • number2: The second number.
  • Returns: The greater or smaller number.
  • Differences from orig. SB: none.

Math.Remainder(dividend, divisor)

  • Description: Returns the remainder of division of two numbers.
  • Parameters:
    • dividend: The number to be divided.
    • divisor: The number by which to divide.
  • Returns: The remainder of the division.
  • Differences from orig. SB: none.

Math.GetRandomNumber(maxNumber)

  • Description: Generates a random number between 1 and the specified maximum number.
  • Parameters:
    • maxNumber: The maximum number (inclusive).
  • Returns: A random integer between 1 and maxNumber.
  • Differences from orig. SB: none.

Math.GetRandomBoolean()

  • Description: Returns a random boolean value (true or false).
  • Returns: A random true or false value.
  • Differences from orig. SB: New feature for SBOE

Math.GetRandomString(length)

  • Description: Returns a random string with printable characters of the specified length.
  • Parameters:
    • length: A positive integer specifying the length of the random string.
  • Returns: A random string, or null if an invalid length is provided.
  • Differences from orig. SB: New feature for SBOD.

Math.DoubleToDecimal(number)

  • Description: Converts a double-precision floating-point number to a decimal.
  • Parameters:
    • number: The double-precision floating-point number.
  • Returns: The equivalent decimal value.

Top