eval Operators and Functions (GPL)

Following are the operators and functions that you can use with the eval function. See eval Function (GPL) for information about the eval function.

Table 1. Operators
Operator Meaning Notes
+ Addition or string concatenation Using + with numbers adds the numbers. Using it with strings concatenates the strings.
- Subtraction  
* Multiplication  
/ Division  
() Grouping Grouped expressions are calculated before other expressions.
** Exponentiation  
== Equal  
!= Not equal  
< Less than  
> Greater than  
<= Less than or equal to  
>= Greater than or equal to  
&& Logical AND  
|| Logical OR  
? : Conditional These operators are shorthand for then-else when evaluating a Boolean operand. For example, x>15?”High”:”Low” returns “High” if x > 15. Otherwise, the expression returns “Low”.
Table 2. Mathematical Functions
Function Result Notes
abs(n) The absolute value of n  
acos(n) The inverse cosine (arcosine) of n  
asin(n) The inverse sine (arcsine) of n  
atan(n) The inverse tangent (arctangent) of n  
atanh(n) The hyperbolic inverse tangent (hyperbolic arctangent) of n  
ceil(n) The smallest integer that is greater than n Round up
cos(n) The cosine of n  
cosh(n) The hyperbolic cosine of n  
exp(n) e raised to the power n, where e is the base of the natural logarithms  
floor(n) The largest integer that is less than n Round down
gamma(n) The complete Gamma function of n  
int(n) The value of n truncated to an integer (toward 0)  
lgamma(n) The logarithm of the complete Gamma function of n  
log(n) The natural (base-e) logarithm of n  
log2(n) The base-2 logarithm of n  
log10(n) The base-10 logarithm of n
mod(n, modulus) The remainder when n is divided by modulus  
pow(n, power) The value of n raised to the power of power  
round(n) The integer that results from rounding the absolute value of n and then reaffixing the sign. Numbers ending in 0.5 exactly are rounded away from 0. For example, round(-4.5) rounds to -5.  
sin(n) The sine of n  
sinh(n) The hyperbolic sine of n  
sqrt(n) The positive square root of n  
tan(n) The tangent of n  
tanh(n) The hyperbolic tangent of n  
Table 3. String Functions
Function Result Notes
concatenate(string1, string2) A string that is the concatenation of string1 and string2  
datetostring(date) The string that results when date is converted to a string  
indexof(haystack,needle[,divisor]) A number that indicates the position of the first occurrence of needle in haystack. The optional third argument, divisor, is a number of characters used to divide needle into separate strings. Each substring is used for searching and the function returns the first occurrence of any of the substrings. For example, indexof(x, “abcd”) will return the value of the starting position of the complete string "abcd" in the string variable x; indexof(x, “abcd”, 1) will return the value of the position of the first occurrence of any of the values in the string; and indexof(x, “abcd”, 2) will return the value of the first occurrence of either "ab" or "cd". Divisor must be a positive integer and must divide evenly into the length of needle. Returns 0 if needle does not occur within haystack.  
length(string) A number indicating the length of string  
lowercase(string) string with uppercase letters changed to lowercase and other characters unchanged  
ltrim(string[, char]) string with any leading instances of char removed. If char is not specified, leading blanks are removed. Char must resolve to a single character.  
midstring(string , start, end) The substring beginning at position start of string and ending at end  
numbertostring(n) The string that results when n is converted to a string  
replace(target, old, new) In target, instances of old are replaced with new. All arguments are strings.  
rtrim(string[, char]) string with any trailing instances of char removed. If char is not specified, trailing blanks are removed. Char must resolve to a single character.  
stringtodate(string) The value of the string expression string as a date  
stringtonumber(string) The value of the string expression string as a number  
substring(string, start, length) The substring beginning at position start of string and running for length length  
trim(string) string with any leading and trailing blanks removed  
uppercase(string) string with lowercase letters changed to uppercase and other characters unchanged  
Table 4. Date and Time Functions
Function Result Notes
date() The current date  
time() The current time  
Table 5. Constants
Constant Meaning Notes
true True  
false False  
pi pi  
e Euler's number or the base of the natural logarithm