Class MathFunctions

java.lang.Object
com.scriptbasic.utility.functions.MathFunctions

public class MathFunctions extends Object
This class contains static methods that are place holders to register the methods of the class java.lang.Math for the BASIC programs. If the documentation of the method does not specify different then the method in this class can be invoked directly from a BASIC program and does exactly the same as the method of the same name in the class java.lang.Math.

When a method accepts Number arguments it means that the BASIC can call the function with integer or with floating point arguments.

Author:
Peter Verhas
  • Field Details

    • roundingMode

      public static RoundingMode roundingMode
      Rounding mode used by round function
  • Method Details

    • abs

      public static Number abs(Number x) throws ScriptBasicException
      Throws:
      ScriptBasicException
    • acos

      public static double acos(double x)
    • asin

      public static double asin(double x)
    • atan

      public static double atan(double x)
    • atan2

      public static double atan2(double x, double y)
    • cbrt

      public static double cbrt(double x)
    • ceil

      public static double ceil(double x)
    • copySign

      public static double copySign(double magnitude, double sign)
    • cos

      public static double cos(double x)
    • cosh

      public static double cosh(double x)
    • exp

      public static double exp(double a)
    • expm1

      public static double expm1(double x)
    • floatF

      public static Double floatF(Object s)
      Convert a value to floating point. This method can be called directly from the BASIC program and it will return a java Double, that is internally a BASIC float. (Note that ScriptBasic for Java does not use float or int, only Long and Double.)

      Use this function from the BASIC program if the BASIC interpreter does not convert automatically a number to floating point but you need a floating point number and not an integer.

      Parameters:
      s - the number to convert
      Returns:
      the converted number or null, which means undefined in BASIC in case the parameter s passed can not be converted to floating point
    • integer

      public static Long integer(Object s)
      Convert a value to integer. This method can be called directly from the BASIC program and it will return a java Long, that is internally a BASIC integer. (Note that ScriptBasic for Java does not use float or int, only Long and Double.)

      Use this function from the BASIC program if the BASIC interpreter does not convert automatically a number to integer but you need an integer number and not a floating point number.

      Parameters:
      s - the number to convert
      Returns:
      the converted number or null, which means undefined in BASIC in case the parameter s passed can not be converted to integer
    • floor

      public static double floor(double x)
    • getExponent

      public static Long getExponent(double d)
    • hypot

      public static double hypot(double x, double y)
    • IEEEremainder

      public static double IEEEremainder(double f1, double f2)
    • log

      public static double log(double x)
    • log10

      public static double log10(double x)
    • log1p

      public static double log1p(double x)
    • max

      public static Number max(Number a, Number b)
    • min

      public static Number min(Number a, Number b)
    • pow

      public static double pow(double a, double b)
    • random

      public static double random()
    • rint

      public static double rint(double a)
    • round

      public static Number round(double value, Integer numdecimalplaces)
      Returns a number rounded to a specified number of decimal places. This function returns something commonly referred to as bankers rounding. So be careful before using this function. Same behavior has 'round' in VBA.
      Parameters:
      value - Numeric value being rounded
      numdecimalplaces - Number indicating how many places to the right of the decimal are included in the rounding.
      Returns:
      rounded value
    • scalb

      public static double scalb(double d, int scaleFactor)
    • signum

      public static double signum(double d)
    • sin

      public static double sin(double x)
    • sinh

      public static double sinh(double x)
    • sqrt

      public static double sqrt(double a)
    • tan

      public static double tan(double x)
    • tanh

      public static double tanh(double x)
    • toDegrees

      public static double toDegrees(double angrad)
    • toRadians

      public static double toRadians(double angdeg)