Math

Mathematical functions are used for a variety of mathematics-oriented calculations and operations.

Abs()

Abs(BigInt, a)

Returns the absolute value of a BigInt value. If the argument is not negative, the argument will be returned. If the argument is negative, the negation of the argument will be returned.

Parameter

a - A BigInt value.

Return value

The return value is an Integer.

Example

The return value of the following statements is 3534.

Abs(-3534) and Abs(3534)

Abs(currency, a)

Returns the absolute value of a Currency value. If the argument is not negative, the argument will be returned. If the argument is negative, the negation of the argument will be returned.

Parameter

a - A Currency value.

Return value

The return value is a Currency.

Example

The return value of the following statement is $3.67.

Abs($3.67) and Abs($-3.67)

Abs(double, a)

Returns the absolute value of a Double value. If the argument is not negative, the argument will be returned. If the argument is negative, the negation of the argument will be returned.

Parameter

a - A Double value.

Return value

The return value is a Number.

Example

The return value of the following statements is 2.4785.

Abs(2.4785) and Abs(-2.4785)

atan(number)

Returns a number specifying the arctangent of the given number parameter. In other words, it returns the angle whose tangent is the given number parameter. This function works in a similar way to the Java Math function with the same name. The range of values returned by atan is between -pi/2 and pi/2 radians.

Parameter

number - A Number value.

Return value

Number value, which is an angle specified in number of radians.

Example

atan(1) - Returns an angle of 0.7854 radians (rounded to 4 radians). To convert this angle to degrees multiply by 180 / pi. For instance, atan (1) * 180 / pi is 45 degrees.

Average()

Average(DBField a)

The function is used to get the average value of the values referred to by the argument.

Parameter

a - Values of DBField or formula field. Can be Number or Currency data type.

Return value

The return value can be Number or Currency.

Examples

Average(DBField a, String groupby)

This function is used to get the average value of values referred to by the argument.

Parameters

Return value

The result value can be Number or Currency, and is depent on the data type of the first argument respectively.

Examples

Average(Number a[])

This function computes the average of all the values in the array.

Parameter

a - A Number or Currency array.

Return value

The return value is a Number or a Currency.

Examples

Note: If a field is assigned to a variable, for example x, the variable x will lose the characteristic of representing a group of values. The following formula will then be treated as incorrect.

Number x = @dbfield;
Number y = Average(x); // system will prompt you that there is no such kind of function.

cos(number)

Returns a number specifying the cosine of an angle given in radians. It takes a right-angle triangle, and returns the length of the side adjacent to the specified angle divided by the length of the hypotenuse.

Parameter

number - An angle in number of radians.

Return value

Number value between 1 and -1.

Examples

Count()

Count(Array a[ ])

This function computes the number of the values in an array.

Parameter

a - A Double array.

Return value

The return value is an Integer.

Examples

Count(DBField a)

The function is used to count the number of values referred to by the argument.

Parameter

a - Values of DBField or formula field.

Return value

Returns a Number type value.

Examples

Count(DBField a, String groupby)

The function is used to count the number of values referred to by the first argument.

Parameters

Return value

Returns a Number type value.

Examples

Note: If a field is assigned to a variable, for example x, the variable x will lose the characteristic of representing a group of values. The following formula will then be treated as incorrect.

Number x = @dbfield;
Number y = Count(x); // system will prompt you that there is no such kind of function.

DistinctCount()

DistinctCount(DBField a)

This function computes the number of distinct values referred to by a DBField.

Parameter

a - Values of a DBField or a formula field.

Return value

The return value is an Integer.

Example

If you build a report about customer order, the return value of the following statement is 19.

DistinctCount(@"Order Date")

DistinctCount(DBField a, String groupby)

This function is used to count the number of distinct values referred to by the first argument.

Parameters

Return value

Returns a Number type value.

Examples

DistinctCount(Number a[ ])

This function computes the number of distinct values in an array.

Parameter

a - A Number array.

Return value

The return value is an Integer.

Example

The return value of the following statement is 4.

DistinctCount([1.45, 2.63, 38.1, 1.45, 23.9])

Note: If a field is assigned to a variable, for example x, the variable x will lose the characteristic of representing a group of values. The following formula will be treated as incorrect.

Number x = @dbfield;
Number y = DistinctCount(x); // system will prompt you that there is no such kind of function.

e()

Returns the Mathematical value of e, which is 2.7182818 (if rounded to 7 decimal places).

exp(Number)

Returns a number specifying e (the base of natural logarithms) raised to a power. The value of e is approximately 2.7182818284590452354. This function works like the Java Math function with the same name. Numeric overflow occurs if the given number parameter is larger than approximately 705.

Parameter

inNumber - Number value that specifies a power.

Return value

A number which is the value of e ^ Number.

Examples

integDiv(numbera, numberb)

Returns the integer portion of the value numbera/numberb.

Parameters

Return value

Whole Number value.

Example

integDiv(33, 2) - Returns 16.

log(number)

Returns a number specifying the natural logarithm of a given number. The natural logarithm is the logarithm to the base e, where e is approximately 2.7182818284590452354. If the value of number is less than 0, the function will return NaN.

Parameter

number - The Number value that you want to calculate on.

Return value

The number which is the value of ln(Number).

Examples

Maximum()

Maximum(a[ ])

This function returns the highest value in an array.

Parameter

a - An array, data type can be Number.

Return value

Returns a Number value.

Example

Maximum(DBField a)

This function is used to pick up the maximum value from the values referred to by the argument.

Parameter

a - Values of a DBField or a formula field.

Return value

The returned value type is dependent on the data type of the parameter. It may be Number, Currency, String, Date, Time, DateTime or Boolean.

Examples

Maximum(DBField a, String groupby)

This function is used to pick up the maximum value from the values referred to by the first argument.

Parameters

Return value

The returned type is dependent on the data type of the first argument. It may be Number, Currency, String, Date, Time, DateTime or Boolean.

Examples

Note: If a field is assigned to another variable, for example x, the variable x will lose the characteristic of representing a group of values. The following formula will then be treated as incorrect.

Number x = @dbfield;
Number y = Maximum(x); // system will prompt you that there is no such kind of function.

Minimum()

Minimum(a[ ])

This function returns the lowest value in an array.

Parameter

a - An array which type can be Number.

Return value

Returns a Number value.

Examples

Minimum(DBField a)

This function is used to pick up the minimum value from the values referred to by the argument.

Parameter

a - Values of a DBField or a formula field.

Return value

The returned value type is dependent on the data type of the parameter. It can be Number, Currency, String, Date, Time, DateTime or Boolean.

Examples

Minimum(DBfield a, String groupby)

This function is used to pick up the minimum value from the values referred to by the first argument.

Parameters

Return value

The returned value type is dependent on the first argument. It may be Number, Currency, String, Date, Time, DateTime or Boolean.

Examples

Note: If a field is assigned to a variable, for example x, the variable x will lose the characteristic of representing a group of values. The following formula will then be treated as incorrect.

Number x = @dbfield;
Number y = Minimum(x); // system will prompt you that there is no such kind of function.

MRound()

Returns a number that is a multiple of the second parameter and at the same time is nearest to the first parameter. This function rounds up (away from zero) if the remainder of the division is greater than or equal to half of the value of the second parameter.

Overloads

MRound(Number,Number)

MRound(Currency,Number)

MRound(Currency,Currency)

Parameters

Note: Regardless of the positive/negative sign of the second parameter, the result of the function takes the positive/negative sign of the first parameter.

Return value

A number.

Expression

Take MRound(Currency,Number) for an example:

MRound(Currency,Number) = Number*(Integer(Currency/Number) + (1 if Remainder(Currency/Number) >=Number/2, otherwise 0)

Examples

pi()

Returns the Mathematical value of pi, which is 3.1415926 (if rounded to 7 decimal places).

PopulationStdDev()

This function computes the population standard deviation of the values referred to by the argument.

Parameters

Return value

Returns a Number type value.

Examples

Note: If a field is assigned to a variable, for example x, the variable x will lose the characteristic of representing a group of values. Therefore, the following formula will be treated as incorrect.

Number x = @dbfield;
Number y = PopulationStdDev(x); // system will prompt you that there is no such kind of function.

PopulationVariance()

This function computes the population variance of the values referred to by the argument.

Parameters

Return value

Returns a Number type value.

Examples

Note: If a field is assigned to a variable, for example x, the variable x will lose the characteristic of representing a group of values. Therefore, the following formula will be treated as incorrect.

Number x = @dbfield;
Number y = PopulationVariance(x); // system will prompt you that there is no such kind of function.

pow(numbera, numberb)

Returns the value of numbera ^ numberb.

Paremeters

Examples

random(), random(seed)

Returns a random number greater than or equal to 0 and less than 1. If seed is equal to 0, Random returns the random number that was returned from the previous call to random. If seed is not supplied or is greater than 0, then Random will return the next random number in the internally generated sequence of random numbers. If seed is less than 0, then Random will use this value of seed to start a new random number sequence and returns the first value in the sequence. This function is typically used when your formula requires a randomly generated number, for example, statistical calculations or selecting records at random to limit the data in a report.

Overloads

Parameter

seed - An optional Number value parameter.

Return value

A Number value.

Examples

Note: You can call Random without ever starting a new random number sequence by specifying a negative seed parameter. If you do so, an internal seed will be generated using the system clock. The reason to start a new random number sequence by calling Random with a negative seed parameter, and then making subsequent calls to Random without a parameter (or with a positive parameter) is so that the report will look exactly the same every time it is previewed. In other words, it allows you to make use of random numbers, but to return a reproducible result.

Remainder(Integer a, Integer b)

This function is used to evaluate the remainder after numerator has been divided by a denominator.

Parameters

Return value

The return value is an Integer.

Examples

Round()

Round(Number a)

This function returns the integer portion after a specified number has been rounded.

Parameter

a - A Double value.

Return value

The return value is an Integer.

Example

The return value of the following statement is 3.00.

Round(2.754)

Round(Number a, integer b)

This function is used to round to a specified scale determined by argument b for Double value a.

Parameters

Return value

The return value is a Number.

Example

The return value of the following statement is 2.46.

Round(2.4576, 2)

Round(Number a, integer b, integer c)

This function is used to round to a specified scale determined by argument b and a specified rounding mode determined by argument c for Double value a.

Parameters

Return Value

The return value is a Number.

Example

The return value of the following statement is 2.03.

Round(2.021, 2, 0)

Round (Number a, Integer b, String c)

This function is use to round to a specified scale determined by argument b using the rounding mode c.

Parameters

Return Value

The return value is a number.

Example

The return value of the following statement is 123.457.

Round(123.4567, 3, 'UP')

Note: The digits of the decimal fraction of the rounded number must be bigger than the scale specified in the formula.

RunningAvg()

Function

Description

This function takes the average of all the numerical values in a field on running records. For details about the arguments, return type, and examples, refer to Average().

RunningCount()

Function

Description

This function takes a total count on running records of the values in a field. For details about the arguments, return type, and examples, refer to Count().

RunningDistinctCount()

Function

Description

This function takes a total count of all the distinct fields in a report on running records. For details about the arguments, return type, and examples, refer to DistinctCount().

RunningMaximum()

Function

Description

This function finds the largest numerical value in a field on running records. For details about the arguments, return type, and examples, refer to Maximum().

RunningMinimum()

Function

Description

This function finds the smallest numerical value in a field on running records. For details about the arguments, return type, and examples, refer to Minimum().

RunningSum()

Function

Description

This function sums up all the numerical values in a field on running records. For details about the arguments, return type, and examples, refer to Sum().

sgn(data)

Returns the sign value of the given number (whose value is data). If data is greater than 0, it will return 1. If data is less than 0, it will return -1. If data is equal to 0, it will return 0.

Parameter

data - The value you want to know the sign of.

Return value

1, 0 or -1.

Examples

sin(number)

Returns a number specifying the sine of an angle given in radians. It takes a right-angle triangle, and returns the length of the side opposite to the specified angle divided by the length of the hypotenuse.

Parameter

number - An angle in number of radians.

Return value

Number value between -1 and 1.

Examples

sqr(number)

Returns the square root of a given number. If the value of the number is less than 0, this function returns NaN. It is designed to work like the Java Math function of sqrt().

Parameter

number - A Number value greater than or equal to 0.

Return value

Number value.

Example

sqr(100) - Returns 10.

StdDev()

This function computes the standard deviation of the values referred to by the argument.

Parameters

Return value

Returns a Number value.

Examples

Note: If a field is assigned to a variable, for example x, the variable x will lose the characteristic of representing a group of values. The following formula will then be treated as incorrect.

Number x = @dbfield;
Number y = StdDev( x); // system will prompt you that there is no such kind of function.

Sum()

This function computes the sum of all the values referred to by the argument.

Parameters

Return value

The returned value type is dependent on the parameter. It can be Number, Integer or Currency.

Examples

Note: If a field is assigned to a variable, for example x, the variable x will lose the characteristic of representing a group of values. So, the following formula will be treated as incorrect.

Number x = @dbfield;
Number y = Sum( x); // system will prompt you that there is no such kind of function.

tan(number)

Returns a number specifying the tangent of an angle given in radians. It takes a right-angle triangle, and returns the length of the side opposite the specified angle divided by the length of the side adjacent to the angle.

Parameter

number - An angle in the form of number of radians.

Return value

Number value.

Examples

ToBinary(Integer a)

This function changes a specified integer to its binary form.

Parameter

a - A BigInt value.

Return value

The return value is a String.

Example

The return value of the following statement is 1011.

ToBinary(11)

ToHex(Integer a)

This function returns the HEX form of a specified value.

Parameter

a - A BigInt value.

Return value

The return value is a String.

Example

The return value of the following statement is 20.

ToHex(32)

ToInt(number a)

This function changes a specified number to an Integer.

Parameter

a - A Number value.

Return value

The return value is an Integer.

Example

The return value of the following statement is 100.

ToInt(100.1)

ToOctal(Integer a)

This function returns the octal form of a specified value.

Parameter

a - A BigInt value.

Return value

The return value is a String.

Example

The return value of the following statement is 64.

ToOctal(52)

Truncate()

Truncate(Number a)

This function returns a number by truncating the decimal portion.

Parameter

a - A Double value to be truncated.

Return value

The return value is a Number.

Example

The return value of the following statement is 25.00.

Truncate(25.4321)

Truncate(Number a, Integer b)

This function returns a number by truncating the number at the decimal point. The number is truncated to the decimal place indicated by argument b, and the function returns a fractional number.

Parameters

Return value

The return value is a Number.

Example

The return value of the following statement is 25.430.

Truncate(25.432, 2)

Variance()

This function computes the variance of all the values referred to by the argument.

Parameters

Return value

Returns a Number type value.

Examples

Note: If a field_variable is assigned to a variable, for example x, the variable x will lose the characteristic of representing a group of values. So, the following formula will be treated as incorrect.

Number x = @dbfield;
Number y = Variance(x); // system will prompt you that there is no such kind of function.