You are here: Using BML > Functions & Scripts > Math Functions

Math Functions

OVERVIEW

Math, or numeric, functions serve many purposes throughout the CPQ Cloud application. Many of them represent basic mathematical and trigonometric functions.

ADMINISTRATION

Closedacos(x)

This function returns the arccosine of the number or angle in the range of 0 through π.Example Use Case: Find the inverse function of the cosine of an angle.

Syntax: acos(x)

Parameters:

Return Type: Float

Example of acos():


Closedasin()

The usual notation of the inverse trig function arcsine is y = arcsine(x), which is also defined as x = sin(y). This notation is the same for arccosine and arctangent.This function returns the arcsine of a number or angle. The range is: -π/2 ≤ y ≤ π/2 or -90˚ ≤ y ≤ 90˚ and the domain is -1 ≤ x ≤ 1. Example Use Case: Find the inverse function of the sine of an angle.

Syntax: asin(x)

Parameters:

Return Type: Float

Example of asin():

If you enter your float variable as (-1), which is the lowest number in the domain, it will return the lowest number in the range, which is -π/2.


Closedatan()

This function returns the arctangent of the number or angle, the range of which is: -π/2 ≤ y ≤ π/2. Example Use Case: Find the inverse function of the tangent of an angle.

Syntax: atan(x)

Parameters:

Return Type: Float

Example of atan():


Closedceil()

This function converts a float into the next highest whole number. Example Use Case: Rounding up to the next highest whole number.

Syntax: ceil(x)

Parameters:

Return Type: Float

Example of ceil():


Closedcos()

This function returns the cosine of the number/angle. Example Use Case: Find the ratio of the side adjacent the given angle and the hypotenuse.

Syntax: cos(x)

Parameter:

Return Type: Float

Example of cos():


Closedcosh()

This function returns the hyperbolic cosine of a number or angle.

Syntax: cosh(x)

Parameters:

Return Type: Float

Example of cosh():


Closedexp()

This function returns ruler's number e raised to the power of the number passed through the function, also known as the exponential function. Example Use Case: Find whether a quantity grows or decays at a rate proportional to its current value, such as compound interest.

Syntax: exp(x)

Parameters:

Return Type: Float

Example of exp():


Closedfabs()

This function returns the absolute value of a number. Example Use Case: Finding the distance of the quantity from zero.

Syntax: fabs(x)

Parameters:

Return Type: Float

Example of fabs():


Closedfmod()

This function returns the remainder after division.x, y

Syntax: fmod(x, y)

Parameters:

Return Type: Float

Example of fmod():

If you were to use long division, the answer is 5 with a remainder of 2. If you plus this operation into your calculator, you will see the answer is 5.6667, because the remained is being divided by the divisor.


Closedhypot()

This function returns the sqrt(x2 + y2) without intermediaries. Example: sqrt(32 + 42) = sqrt(25) = 5.0 or -5.0.

Syntax: hypot(x, y)

Parameters:

Return Type: Float

Example of hypot():

As you can see, we have declared three variables. The two that were required for this function to work, as well as a third variable so we can round the results of the hypot() function. The result of this function return a rather large number. Using the round() function, we were able to round to the third decimal place.


Closedinteger()

This function returns the integer portion of a float number. For example, this function would return 14 for the number 14.3345324. Example Use Case: Returning an attribute as an integer, without rounding.

Syntax: integer(x)

Parameters:

Return Type: Integer

Example of integer():


ClosedjNaN


Closedlog()

This function returns the base-10 logarithm of the number.

Example Use Case: If 1000 = 103, then 3 = log10(1000). The logarithm of 1000 would be 3 because that is how many times you must multiply 10 to get 1000.

Syntax: log(x)

Parameters:

Return Type: Float

Example of log():


Closedln()

This function returns the natural logarithm (base e) of the number.

Syntax: ln(x)

Parameters:

Return Type: Float

Example of ln():


ClosedNaN

This function is deprecated, and no longer supported. It represented a constant for Not a Number.

Use jNaN instead.


Closedpow()

This function returns the value of the first argument raised to the power of the second argument. Example Use Case: Finding the product obtained from multiplying a quantity by itself one or more times.

Syntax: pow(x, y)

Parameters:

Return Type: Float

Example of pow():


Closedround()

This function returns the rounded value of a number up to a certain decimal point. Example Use Case: For returning float values that represent currency. You may want to round to a certain decimal place.

Syntax: round(x)

Parameters:

Return Type: Float

Example of round():


Closedsin()

This function returns the trigonometric sine of the number/angle. Example Use Case: Finding the ratio of the size opposite the given angle and the hypotenuse.

Syntax: sin(x)

Parameters:

Return Type: Float

Example of sin():


Closedsinh()

This function returns the hyperbolic sine of a number or angle.

Syntax: sinh(x)

Parameters:

Return Type: Float

Example of sinh():


Closedsqrt()

This function returns the positive square root of a number.

Syntax: sqrt(x)

Parameters:

Return Type: Float

Example of sqrt():


Closedtan()

This function returns the tangent of the number/angle. Example Use Case: Find the ratio of the side opposite the given angel to the adjacent side.

Syntax: tan(x)

Parameters:

Return Type: Float

Example of tan():


Closedtanh()

This function returns the hyperbolic tangent of a number or angle.

Syntax: tanh(x)

Parameters:

Return Type: Float

Example of tanh():


NOTES

    NULL and blank Integer values are treated as separate values.

    - NULL= 0
    - Blank = ""

    If you use logic that tests for NULL values in rule conditions or BML, this logic should be updated.

    Using "null" as an attribute value is strongly discouraged.

RELATED TOPICS

Related Topics Link IconSee Also