Rules can contain any of the inbuilt mathematical functions listed in the table below:

Name | Description |

abs | Returns the absolute value of a number |

ceil | Returns the smallest integer greater than or equal to the argument |

floor | Returns the largest integer less than or equal to the argument |

log | Returns the logarithm of a number |

log10 | Returns the base 10 logarithm of a number |

max | Returns the larger of two numbers |

min | Returns the smaller of two numbers |

pow | Returns the result of raising one number to the power of another number |

round | Returns a number rounded to the nearest integer |

sign | Returns a value indicating the sign of a number |

sqrt | Returns the square root of a number |

Returns the absolute value of a number.

Signature

double abs(double x)

Parameters

x : The number to return the absolute value of.

Returns

If x is not negative it returns x. If x is negative it returns the negation of x. If x is zero it returns zero.

Examples

abs(1) = 1 abs(0) = 0 abs(-1) = 1

Returns the smallest integer greater than or equal to the argument.

Signature

double ceil(double x)

Parameters

x : The number to round.

Returns

The smallest integer greater than or equal to x. This is sometimes called rounding towards positive infinity.

Examples

ceil(1.6) = 2 ceil(1.5) = 2 ceil(1.4) = 2 ceil(1) = 1 ceil(0) = 0 ceil(-1) = -1 ceil(-1.4) = -1 ceil(-1.5) = -1 ceil(-1.6) = -1

Returns the largest integer less than or equal to the argument.

Signature

double floor(double x)

Parameters

x : The number to round.

Returns

The largest integer less than or equal to x. This is sometimes called rounding towards negative infinity.

Examples

floor(1.6) = 1 floor(1.5) = 1 floor(1.4) = 1 floor(1) = 1 floor(0) = 0 floor(-1) = -1 floor(-1.4) = -2 floor(-1.5) = -2 floor(-1.6) = -2

Returns the natural (base e) logarithm of a number.

Signature

double log(double x)

Parameters

x : The number whose logarithm is to be returned.

Returns

The natural (base e) logarithm of x. If x is zero or negative then zero is returned.

Examples

log(1000) = 6.90775527898214 log(100) = 4.60517018598809 log(10) = 2.30258509299405 log(1) = 0 log(0.1) = -2.30258509299405

Returns the base 10 logarithm of a number.

Signature

double log10(double x)

Parameters

x : The number whose logarithm is to be returned.

Returns

The base 10 logarithm of x. If x is zero or negative then zero is returned.

Examples

log10(1000) = 3 log10(100) = 2 log10(10) = 1 log10(1) = 0 log10(0.1) = -1

Returns the larger of two numbers.

Signature

double max(double x, double y)

Parameters

x : The first of the two numbers to be compared.

y : The second of the two numbers to be compared.

Returns

The larger of the two numbers x and y. If x and y are equal then the same number is returned.

Examples

max(1, 0) = 1 max(0, -1) = 0 max(-1.3, -3.5) = -1.3

Returns the smaller of two numbers.

Signature

double min(double x, double y)

Parameters

x : The first of the two numbers to be compared.

y : The second of the two numbers to be compared.

Returns

The smaller of the two numbers x and y. If x and y are equal then the same number is returned.

Examples

min(1, 0) = 0 min(0, -1) = -1 min(-1.3, -3.5) = -3.5

Returns the result of raising one number to the power of another number.

Signature

double pow(double x, double y)

Parameters

x : A number to be raised to a power.

y : The power to raise x to.

Returns

x raised to the power y. If the result is positive infinity (e.g. x = 0 and y < 0) or not a number (e.g. x < 0 and y is not an integer) then zero is returned.

Examples

pow(2, 3) = 8 pow(100, 2) = 10000

Returns a number rounded to the nearest integer.

Signature

double round(double x)

Parameters

x : The number to round.

Returns

The integer nearest to x. If x is exactly halfway between two integers then it is rounded to the integer that is further from zero.

Examples

round(1.6) = 2 round(1.5) = 2 round(1.4) = 1 round(1) = 1 round(0) = 0 round(-1) = -1 round(-1.4) = -1 round(-1.5) = -2 round(-1.6) = -2

Returns a value indicating the sign of a number.

Signature

double sign(double x)

Parameters

x : The number to determine the sign of.

Returns

-1 if x is less than zero.

0 if x is equal to zero.

1 if x is greater than zero.

Examples

sign(10) = 1 sign(0) = 0 sign(-10) = -1

Returns the square root of a number.

Signature

double sqrt(double x)

Parameters

x : The number to square root.

Returns

The positive square root of x. If x is negative then zero is returned.

Examples

sqrt(64) = 8 sqrt(2) = 1.4142135623731 sqrt(0) = 0