Chapter 3. Function Library

This section describes the built-in subroutines in the Qore language making up the system function library. Following is a list of function categories, and below there is an alphabetically-ordered list of all Qore built-in functions.

Table 3.1. System Function Category List


Each builtin function or method has flags that describe its properties. The following table provides the key to the flags as given in the function and method lists.

Table 3.2. Code Flags

Abbr

Description

NOOP

Code with this flag makes no calculations, but rather returns a constant value. This flag is given to function and method variants that return a default value depending on the type of argument(s). When variants with this flag are resolved at parse time, a call-with-type-errors warning is raised (assuming this warning is enabled).

RT_NOOP

Code with this flag makes no calculations, but rather returns a constant value. This flag is given to function and method variants that return a default value depending on the type of argument(s). When variants with this flag are resolved at parse time, a call-with-type-errors warning is raised (assuming this warning is enabled), unless PO_REQUIRE_TYPES or PO_STRICT_ARGS is set. If PO_REQUIRE_TYPES or PO_STRICT_ARGS is set, then these variants are inaccessible; resolving to a variant with this flag set at parse time or run time causes an exception to be thrown. These variants are included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

CONST

This flag indicates that the function or method has no side effects and does not throw any exceptions (see also RET_VALUE_ONLY).

RET_VALUE_ONLY

This flag indicates that the function or method has no side effects but could throw an exception (see also CONST).

DEPRECATED

Code with this flag is deprecated and may be removed in a future version of Qore; if a variant with this flag is resolved at parse time, a deprecated warning is raised (assuming this warning is enabled).


Table 3.3. System Function Library

Function Name

Ex?

Brief Description

nothing abort()

N

aborts the process

float abs(softfloat)

int abs(int)

float abs() (RT_NOOP)

N

Returns the absolute value of the argument passed

float acos(any)

N

Returns the arc cosine of the number passed in radians

float asin(softfloat)

float asin() (RT_NOOP)

N

Returns the arc sine of the number passed in radians.

float atan(softfloat)

float atan() (RT_NOOP)

N

Returns the arc tangent of the number passed in radians.

string backquote(string)

nothing backquote() (RT_NOOP)

Y

Executes a process and returns a string of the output (stdout only)

string basename(string)

nothing basename() (RT_NOOP)

N

Returns a string giving the last element of a file path.

binary binary(softstring) (CONST)

binary binary(binary) (CONST)

binary binary(null) (CONST)

binary binary() (CONST)

N

Returns a binary data type of the data passed.

string binary_to_string(binary)

string binary_to_string(binary, string)

Y

Returns a string created from the binary data passed.

int bindex(softstring, softstring, softint = 0)

int bindex() (RT_NOOP)

N

Returns the byte position of a substring within a string and takes an optional starting offset

binary blowfish_encrypt_cbc(data, data, data = defaultIV)

Y

Encrypts data using the Cipher Block Chaining function for the blowfish algorithm.

binary blowfish_decrypt_cbc(binary, data, data = defaultIV)

Y

Decrypts data using the Cipher Block Chaining function for the blowfish algorithm.

string blowfish_decrypt_cbc_to_string(binary, data, data = defaultIV)

Y

Decrypts data to a string using the Cipher Block Chaining function for the blowfish algorithm.

bool boolean(softbool) (CONST)

bool boolean(null) (CONST)

bool boolean() (CONST)

N

Converts the argument to a boolean value.

int brindex(softstring, softstring, softint = -1)

int brindex() (RT_NOOP)

N

Returns the byte position of a substring within a string as searched from the end of the string and takes an optional starting offset

binary bunzip2_to_binary(binary)

nothing bunzip2_to_binary() (RT_NOOP)

Y

Uncompresses the given data with the bzip2 algorithm and returns the uncompressed data as a binary.

string bunzip2_to_string(binary, string = defaultEncoding)

nothing bunzip2_to_string() (RT_NOOP)

Y

Uncompresses the given data with the bzip2 algorithm and returns the uncompressed data as a string.

binary bzip2(data, softint = 9)

nothing bzip2() (RT_NOOP)

Y

Compresses the given data with the bzip2 algorithm and returns the uncompressed data as a binary.

any call_builtin_function(string, ...)

Y

Calls a builtin function identified by the first string argument and returns the return value, passing the remaining arguments after the function name to the function

any call_builtin_function_args(string, list)

any call_builtin_function_args(string, any)

Y

Calls a builtin function identified by the first string argument and returns the return value, using the argument after the function name as a list of arguments to pass to the function.

any call_function(string, ...)

any call_function(code, ...)

Y

Calls a function, closure, or call reference and returns the return value, passing the remaining arguments after the function name to the function (or call reference).

any call_function_args(string, list)

any call_function_args(string, any)

any call_function_args(code, list)

any call_function_args(code, any)

Y

Calls a function, closure, or call reference and returns the return value, using the argument after the function name as a list of arguments to pass to the function, closure, or call reference.

any callObjectMethod(object, string)

nothing callObjectMethod() (RT_NOOP)

Y

calls a method given by a string of the object passed, passing the remaining arguments to the method as arguments

any callObjectMethodArgs(object, string, list)

any callObjectMethodArgs(object, string, any)

nothing callObjectMethodArgs() (RT_NOOP)

Y

calls a method given by a string of the object passed, using the argument after the method name as the list of arguments to pass to the method

binary cast5_encrypt_cbc(data, data, data = defaultIV)

Y

Encrypts data using the Cipher Block Chaining function for the CAST5 algorithm.

binary cast5_decrypt_cbc(binary, data, data = defaultIV)

Y

Decrypts data using the Cipher Block Chaining function for the CAST5 algorithm.

string cast5_decrypt_cbc_to_string(binary, data, data = defaultIV)

Y

Decrypts data to a string using the Cipher Block Chaining function for the CAST5 algorithm.

float cbrt(softfloat)

float cbrt() (RT_NOOP)

N

Returns the cube root of the number passed.

float ceil(softfloat)

float ceil() (RT_NOOP)

N

Returns a value rounded up to the next highest integer

int chdir(string)

Y

Changes the current working directory.

int chmod(string, int)

Y

Changes the mode of a file.

string chomp(string)

any chomp(reference)

N

Removes the trailing end-of-line indicator from a string and returns the new string (also see the chomp operator); also accepts variable references to do modifications in-place.

int chown(string, softint = -1, softint = -1)

Y

Changes the user and group owners of a file (if the current user has permission to do so), follows symbolic links.

string chr(softint)

string chr(any) (NOOP)

nothing chr() (RT_NOOP)

N

Returns a string containing a single ASCII character represented by the numeric value passed.

int clock_getmicros() (CONST)

N

Returns the system time in microseconds (1/1000000 second intervals) since Jan 1, 1970 00:00:00Z.

int clock_getmillis() (CONST)

N

Returns the system time in milliseconds (1/1000 second intervals) since Jan 1, 1970 00:00:00Z.

int clock_getnanos() (CONST)

N

Returns the system time in nanoseconds (1/1000000000 second intervals) since Jan 1, 1970 00:00:00.

binary compress(data, softint = -1)

nothing compress() (RT_NOOP)

Y

Performs zlib-based "deflate" data compression (RFC 1951) and returns a binary object of the compressed data.

string convert_encoding(string, string) (CONST)

nothing convert_encoding() (RT_NOOP)

Y

Performs explicit string character encoding conversions.

float cos(softfloat) (CONST)

float cos() (RT_NOOP)

N

Returns the cosine of the number in radians passed.

float cosh(softfloat) (CONST)

float cosh() (RT_NOOP)

N

Returns the hyperbolic cosine of the number passed.

date date(string) (CONST)

date date(string, string) (CONST)

date date(softint) (CONST)

date date(null) (CONST)

date date() (CONST)

N

Converts the argument passed to a date.

hash date_info(date $date) (CONST)

hash date_info() (CONST)

N

Returns a hash of broken-down date/time information for the given date argument; if the variant with no argument is used, then the current date/time is assumed.

date date_ms(softint) (CONST)

date date_ms() (RT_NOOP)

N

Converts an integer argument as a millisecond offset from January 1, 1970Z to a date.

date date_us(softint) (CONST)

date date_us() (RT_NOOP)

N

Converts an integer argument as a microsecond offset from January 1, 1970Z to a date.

date days(softint) (CONST)

date days() (RT_NOOP)

N

Returns a relative date in days for date arithmetic.

string decode_url(string) (CONST)

nothing decode_url() (RT_NOOP)

N

Decodes percent numeric codes in a URL string and returns the decoded string.

delete_all_thread_data()

N

Deletes all keys in the thread-local data hash.

nothing delete_thread_data(list)

nothing delete_thread_data(...)

N

Deletes the data associated to one or more keys in the thread-local data hash (destroys any objects as well).

binary des_encrypt_cbc(data, data, data = defaultIV)

Y

Encrypts data using the Cipher Block Chaining function for the DES algorithm.

binary des_decrypt_cbc(binary, data, data = defaultIV)

Y

Decrypts data using the Cipher Block Chaining function for the DES algorithm.

string des_decrypt_cbc_to_string(binary, data, data = defaultIV)

Y

Decrypts data using the Cipher Block Chaining function for the DES algorithm.

binary des_ede_encrypt_cbc(data, data, data = defaultIV)

Y

Encrypts data using the Cipher Block Chaining function for the two-key triple DES algorithm.

binary des_ede_decrypt_cbc(binary, data, data = defaultIV)

Y

Decrypts data using the Cipher Block Chaining function for the two-key triple DES algorithm.

string des_ede_decrypt_cbc_to_string(binary, data, data = defaultIV)

Y

Decrypts data to a string using the Cipher Block Chaining function for the two-key triple DES algorithm.

binary des_ede3_encrypt_cbc(data, data, data = defaultIV)

Y

Encrypts data using the Cipher Block Chaining function for the three-key triple DES algorithm.

binary des_ede3_decrypt_cbc(binary, data, data = defaultIV)

Y

Decrypts data using the Cipher Block Chaining function for the three-key triple DES algorithm.

string des_ede3_decrypt_cbc_to_string(binary, data, data = defaultIV)

Y

Decrypts data to a string using the Cipher Block Chaining function for the three-key triple DES algorithm.

binary desx_encrypt_cbc(data, data, data = defaultIV)

Y

Encrypts data using the Cipher Block Chaining function for RSA's DESX algorithm.

binary desx_decrypt_cbc(binary, data, data = defaultIV)

Y

Encrypts data using the Cipher Block Chaining function for RSA's DESX algorithm.

string desx_decrypt_cbc_to_string(binary, data, data = defaultIV)

Y

Encrypts data to a string using the Cipher Block Chaining function for RSA's DESX algorithm.

string DSS(data)

Y

Returns the DSS message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)

binary DSS_bin(data)

Y

Returns the DSS message digest of the supplied argument as a binary object (for strings, the trailing null character is not included in the digest)

string DSS1(data)

Y

Returns the DSS1 message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)

binary DSS1_bin(data)

Y

Returns the DSS1 message digest of the supplied argument as a binary object (for strings, the trailing null character is not included in the digest)

int errno()

N

Returns the value of the system "errno" variable, holding the last error code generated by a system call

nothing exec(string)

nothing exec() (RT_NOOP)

N

Replaces the current process image with another.

bool existsFunction(string) (CONST)

bool existsFunction(code) (NOOP)

nothing existsFunction() (RT_NOOP)

N

Returns True if the function exists in the current program's function name space.

nothing exit(any = 0)

N

Exits the program

float exp(softfloat) (CONST)

float exp() (RT_NOOP)

N

Returns the value of e raised to the power of the argument passed

float exp2(softfloat) (CONST)

float exp2() (RT_NOOP)

N

Returns the value of 2 raised to the power of the argument passed

float expm1(softfloat) (CONST)

float expm1() (RT_NOOP)

N

Returns an equivalent of exp(x) - 1

string f_printf(string, ...)

string f_printf() (RT_NOOP)

Y

"field" printf, field width specifiers are respected. Returns string printed.

string f_sprintf(string, ...) (CONST)

string f_sprintf() (RT_NOOP)

Y

"field" sprintf(), field width specifiers are respected

float float(softfloat) (CONST)

float float(null) (CONST)

float float() (CONST)

N

Returns the argument converted to a floating-point number

float floor(softfloat) (CONST)

float floor() (RT_NOOP)

N

Returns a value rounded down to the nearest integer

nothing flush()

N

Flushes output to the console output with print(), printf(), etc

string force_encoding(string, string) (CONST)

nothing force_encoding() (RT_NOOP)

N

Returns a string tagged with the given character encoding; does not actually change the string data; use only in the case that a string is tagged with the wrong encoding.

int fork()

Y

Creates a duplicate of the current process

string format_date(string, date) (CONST)

nothing format_date() (RT_NOOP)

N

Allows dates to be formatted

string format_number(string, any) (CONST)

nothing format_number() (RT_NOOP)

N

Allows numbers to be formatted with more options than sprintf()

*string functionType(string) (CONST)

nothing functionType() (RT_NOOP)

N

Returns "builtin", "user", or NOTHING according to the function name passed

hash get_all_thread_data() (CONST)

N

Returns the entire thread data hash.

*int get_byte(data, int = 0) (CONST)

N

Returns the byte value at the given byte offset or NOTHING if the offset is not legal for the given data.

int get_days(date) (CONST)

nothing get_days() (RT_NOOP)

N

Returns an integer value representing the days value of the date passed (can be either a relative or absolute date).

string get_default_encoding() (CONST)

N

Returns the name of the default character encoding for the Qore library.

int get_duration_microseconds(date) (CONST)

N

Returns an integer giving the duration in microseconds as described by the argument; if the argument is a relative date, then it is converted to microseconds, if it is absolute, then a number of microseconds between the current time and the time given is returned.

int get_duration_milliseconds(date) (CONST)

N

Returns an integer giving the duration in milliseconds as described by the argument; if the argument is a relative date, then it is converted to milliseconds, if it is absolute, then a number of milliseconds between the current time and the time given is returned.

int get_duration_seconds(date) (CONST)

N

Returns an integer giving the duration in seconds as described by the argument; if the argument is a relative date, then it is converted to seconds, if it is absolute, then a number of seconds between the current time and the time given is returned.

string get_encoding(string) (CONST)

nothing get_encoding() (RT_NOOP)

N

Returns a string describing the character encoding of the string passed.

int get_epoch_seconds(date) (CONST)

nothing get_epoch_seconds() (RT_NOOP)

N

Returns the number of seconds after Jan 1, 1970, 00:00:00Z for the date/time value passed.

int get_hours(date) (CONST)

nothing get_hours() (RT_NOOP)

N

Returns an integer value representing the hours value of the date passed (can be either a relative or absolute date).

int get_microseconds(date) (CONST)

N

Returns an integer value representing the microseconds value of the date passed (can be either a relative or absolute date).

date get_midnight(date) (CONST)

nothing get_midnight() (RT_NOOP)

N

Returns a date/time value representing midnight on the date passed (strips the time from the date passed and returns the new value)

int get_milliseconds(date) (CONST)

nothing get_milliseconds() (RT_NOOP)

N

Returns an integer value representing the milliseconds value of the date passed (can be either a relative or absolute date).

int get_minutes(date) (CONST)

nothing get_minutes() (RT_NOOP)

N

Returns an integer value representing the minutes value of the date passed (can be either a relative or absolute date).

int get_months(date) (CONST)

nothing get_months() (RT_NOOP)

N

Returns an integer value representing the months value of the date passed (can be either a relative or absolute date).

hash get_qore_library_info() (CONST)

N

Returns a hash of build and version information for the qore library.

list get_qore_option_list() (CONST)

N

Returns a list of hashes giving information about qore library options.

int get_seconds(date) (CONST)

nothing get_seconds() (RT_NOOP)

N

Returns an integer value representing the seconds value of the date passed (can be either a relative or absolute date).

*string get_script_path() (CONST)

N

Returns a string giving the path (directory and filename) from which the current script was executed (if known).

*string get_script_dir() (CONST)

N

Returns a string giving the directory from which the current script was executed (if known).

*string get_script_name() (CONST)

N

Returns a string giving the filename of the current script (if known).

any get_thread_data(string) (CONST)

nothing get_thread_data() (RT_NOOP)

N

Returns the value of the thread-local data attached to the key passed

*int get_word_16(data, softint = 0) (CONST)

N

Returns the 16-bit value at the given 2-byte offset or NOTHING if the offset is not legal for the given data; assumes MSB byte order.

*int get_word_16_lsb(data, softint = 0) (CONST)

N

Returns the 16-bit value at the given 2-byte offset or NOTHING if the offset is not legal for the given data; assumes LSB byte order.

*int get_word_32_lsb(data, softint = 0) (CONST)

N

Returns the 32-bit value at the given 4-byte offset or NOTHING if the offset is not legal for the given data; assumes LSB byte order..

*int get_word_64_lsb(data, softint = 0) (CONST)

N

Returns the 64-bit value at the given 8-byte offset or NOTHING if the offset is not legal for the given data; assumes LSB byte order..

int get_years(date) (CONST)

nothing get_years() (RT_NOOP)

N

Returns an integer value representing the years value of the date passed (can be either a relative or absolute date).

softint $family = AF_UNSPEC, softint $flags = 0

list getaddrinfo(*string $node, *softstring $service, softint $family = AF_UNSPEC, softint $flags = 0) (CONST)

Y

Returns a list of address information hashes for the given node name or string address.

hash getAllThreadCallStacks()

N

Returns a hash of call stacks keyed by each TID (thread ID).

*int getByte(data, softint = 0) (CONST)

nothing getByte() (RT_NOOP)

N

Returns the byte value withing the string or binary object passed, or if the offset is out of range, returns NOTHING.

string getClassName(object) (CONST)

nothing getClassName() (RT_NOOP)

N

Returns the class name of the object passed.

*string getcwd()

N

Returns the name of the current working directory or NOTHING if an error occurs.

string getcwd2()

Y

Returns the name of the current working directory and throws an exception if an error occurs.

date getDateFromISOWeek(softint, softint, softint = 1)

Y

Retuns an absolute date value in the local time zone for the ISO-8601 calendar week information passed (year, week number, optional: day); throws an exception if the arguments are invalid.

int getDayOfWeek(date) (CONST)

nothing getDayOfWeek() (RT_NOOP)

N

Returns an integer representing the day of the week for the absolute date passed (0=Sunday, 6=Saturday)

int getDayNumber(date) (CONST)

nothing getDayNumber() (RT_NOOP)

N

Returns an integer representing the ordinal day number in the year for the absolute date passed

*list getDBIDriverCapabilities(string)

nothing getDBIDriverCapabilities() (RT_NOOP)

N

Returns an integer representing the capabilities of a DBI driver or NOTHING if the driver cannot be loaded.

*list getDBIDriverCapabilityList(string)

nothing getDBIDriverCapabilityList() (RT_NOOP)

N

Returns a list of codes representing the capabilities of a DBI driver of NOTHING if the driver cannot be loaded.

*list getDBIDriverList()

N

Returns a list of strings of DBI drivers currently loaded or NOTHING if no drivers have been loaded.

int getegid() (CONST)

Y

Returns the effective group ID of the current process.

int geteuid() (CONST)

Y

Returns the effective user ID of the current process.

list getFeatureList() (CONST)

N

Returns a list of strings of the builtin and module-supplied features of Qore.

*string getenv(string) (CONST)

nothing getenv() (RT_NOOP)

N

Retrieves the value of an environment variable or NOTHING if the variable is not set

int getgid(CONST)

Y

Returns the real group ID of the current process.

*hash getgrnam(string) (CONST)

Y

Returns a hash representing the group information of the group name passed or NOTHING if the group name is not found.

hash getgrnam2(string)

Y

Returns a hash representing the group information of the group name passed; throws an exception if the group name is not found.

*hash getgrgid(softint) (CONST)

Y

Returns a hash representing the group information of the group ID passed or NOTHING if the group ID is not found.

hash getgrgid2(softint)

Y

Returns a hash representing the group information of the group ID passed; throws an exception if the group ID is not found.

*string gethostbyaddr(string, softint = AF_INET) (CONST)

nothing gethostbyaddr() (RT_NOOP)

N

Returns the official hostname corresponding to the network addressed passed or NOTHING if the address cannot be resolved.

*hash gethostbyaddr_long(string, softint = AF_INET) (CONST)

nothing gethostbyaddr_long() (RT_NOOP)

N

Returns all host information corresponding to the network address as a hash or NOTHING if the address cannot be resolved.

*string gethostbyname(string) (CONST)

nothing gethostbyname() (RT_NOOP)

N

Returns the first network address corresponding to the hostname as a string or NOTHING if the name cannot be resolved.

*hash gethostbyname_long(string) (CONST)

N

Returns all host information corresponding to the hostname as a hash or NOTHING if the name cannot be resolved.

string gethostname()

Y

Returns the hostname of the system; throws an exception if an error occurs.

int getISODayOfWeek(date) (CONST)

nothing getISODayOfWeek() (RT_NOOP)

N

Returns an integer representing the ISO-8601 day of the week for the absolute date passed (1=Monday, 7=Sunday)

hash getISOWeekHash(date) (CONST)

nothing getISOWeekHash() (RT_NOOP)

N

Returns a hash representing the ISO-8601 calendar week information for the absolute date passed (hash keys: year, week, day)

string getISOWeekString(date) (CONST)

nothing getISOWeekString() (RT_NOOP)

N

Returns a string representing the ISO-8601 calendar week information for the absolute date passed (ex: 2006-01-01 = "2005-W52-7")

list getMethodList(object) (CONST)

nothing getMethodList() (RT_NOOP)

N

Returns a list of strings of the names of the public and private methods of the class of the object passed as a parameter (does not return base class method names).

hash getModuleHash() (CONST)

N

Returns a hash of hashes describing the currently-loaded Qore modules; the top-level hash keys are the module names.

list getModuleList() (CONST)

N

Returns a list of hashes describing the currently-loaded Qore modules.

int getpid() (CONST)

N

Returns the PID (process ID) of the current process.

int getppid() (CONST)

Y

Returns the parent PID of the current process.

*hash getpwnam(string) (CONST)

Y

Returns a hash representing the user information of the username passed or NOTHING if the username is not found.

hash getpwnam2(string)

Y

Returns a hash representing the user information of the username passed; throws an exception if the username is not found.

*hash getpwuid(softint) (CONST)

Y

Returns a hash representing the user information of the user ID passed or NOTHING if the user ID is not found.

hash getpwuid2(softint)

N

Returns a hash representing the user information of the user ID passed; throws an exception if the user ID is not found.

int gettid() (CONST)

N

Returns the Qore thread ID (TID) of the current thread.

int getuid() (CONST)

Y

Returns the real user ID of the current process.

any getWord32(string, int = 0) (CONST)

any getWord32(binary, int = 0) (CONST)

nothing getWord32() (RT_NOOP)

N

Returns the 32-bit value at the given 4-byte offset or NOTHING if the offset is not legal for the given data.

*list glob(string)

nothing glob() (RT_NOOP)

N

Returns a list of files matching the string argument or NOTHING if the call to glob() fails.

date gmtime(date) (CONST)

date gmtime(softint, softint = 0) (CONST)

date gmtime() (CONST)

N

Returns a date/time value in UTC (GMT).

binary gunzip_to_binary(binary)

nothing gunzip_to_binary() (RT_NOOP)

Y

Uncompresses data compressed with the "gzip" algorithm (RFC 1952) using zlib functions and returns a binary object.

string gunzip_to_string(binary)

string gunzip_to_string(binary, string)

nothing gunzip_to_string() (RT_NOOP)

Y

Uncompresses data compressed with the "gzip" algorithm (RFC 1952) using zlib functions and returns a string.

binary gzip(string, softint = -1)

binary gzip(binary, softint = -1)

nothing gzip() (RT_NOOP)

Y

Performs zlib-based "gzip" data compression (RFC 1952) and returns a binary object of the compressed data.

bool has_key(hash $hash, string $key) (RET_VALUE_ONLY)

bool has_key(object $obj, string $key) (RET_VALUE_ONLY)

Y

Returns True if the given key exists in the hash or object (does not necessarily have to have a value assigned); exceptions are only raised if string encoding errors are encountered or in case of object access errors.

hash hash(list $list)

hash hash(list $keys, list $values)

hash hash(hash $hash) (CONST)

hash hash(object $obj)

hash hash() (CONST)

N

Converts an object or a list to a hash; otherwise returns an empty hash.

list hash_values(hash) (CONST)

nothing hash_values() (RT_NOOP)

N

Returns a list of all the values in the hash argument passed.

int hextoint(string)

Y

Returns an integer for a hexadecimal string value; throws an exception if non-hex digits are found.

*hash hlstat(string)

nothing hlstat() (RT_NOOP)

N

Returns a hash of information about the file corresponding to the pathname argument; does not follow symbolic links (returns information about symbolic links). Returns NOTHING if the stat() call fails.

date hours(softint) (CONST)

date hours() (RT_NOOP)

N

Returns a relative date in hours to be used in date arithmetic.

*hash hstat(string)

nothing hstat() (RT_NOOP)

N

Returns a hash of information about the file corresponding to the pathname argument; follows symbolic links. Returns NOTHING if the stat() call fails.

string html_decode(string) (CONST)

nothing html_decode() (RT_NOOP)

N

Returns a string with any HTML escape codes translated to the original characters

string html_encode(string) (CONST)

nothing html_encode() (RT_NOOP)

N

Returns a string with any characters that can be escaped translated to HTML escape codes.

float hypot(any, softfloat) (CONST)

float hypot(softfloat, any) (CONST)

float hypot() (RT_NOOP)

N

Returns the length of the hypotenuse of a right-angle triangle with sides given as the two arguments.

int index(softstring, softstring, softint = 0) (CONST)

int index() (RT_NOOP)

N

Returns the character position of a substring within a string and takes an optional starting offset

bool inlist(any, list)

bool inlist(any, any)

bool inlist() (RT_NOOP)

N

Returns True if the first argument is a member of the second argument list using comparisons with type conversions.

bool inlist_hard(any, list)

bool inlist_hard(any, any)

N

Returns True if the first argument is a member of the second argument list using comparisons without type conversions.

int int(softint) (CONST)

int int(null) (CONST)

int int() (CONST)

N

Returns the argument converted to an integer

bool is_bdev(string) (CONST)

N

Returns True if the string passed identifies a block device file on the filesystem.

bool is_cdev(string) (CONST)

N

Returns True if the string passed identifies a character device file on the filesystem.

bool is_date_absolute(date) (CONST)

bool is_date_absolute(any) (RT_NOOP)

N

Returns True if an absolute date is passed as an argument, False if not.

bool is_date_relative(date) (CONST)

bool is_date_relative(any) (RT_NOOP)

N

Returns True if a relative date is passed as an argument, False if not.

bool is_dev(string) (CONST)

N

Returns True if the string passed identifies a device file (either block or character) on the filesystem.

bool is_dir(string) (CONST)

N

Returns True if the string passed identifies a directory on the filesystem.

bool is_executable(string) (CONST)

Y

Returns True if the string passed identifies an executable file.

bool is_file(string) (CONST)

N

Returns True if the string passed identifies a regular file on the filesystem.

bool is_link(string) (CONST)

Y

Returns True if the string passed identifies a symbolic link on the filesystem.

bool is_pipe(string) (CONST)

N

Returns True if the string passed identifies a pipe (FIFO) on the filesystem.

bool is_readable(string) (CONST)

N

Returns True if the string passed identifies a file readable by the current user.

bool is_socket(string) (CONST)

Y

Returns True if the string passed identifies a socket on the filesystem.

bool is_writeable(string) (CONST)

N

Returns True if the string passed identifies a file writable by the current user.

string join(string, list) (CONST)

string join(string, ...) (CONST)

nothing join() (RT_NOOP)

N

Creates a string from a list and separator character

int kill(softint, softint = SIGHUP)

nothing kill() (RT_NOOP)

Y

Sends a signal to a process (default: SIGHUP)

int lchown(string, softint = -1, softint = -1)

Y

Changes the user and group owners of a file (if the current user has permission to do so), does not follow symbolic links.

int length(softstring) (CONST)

int length(binary) (CONST)

int length(any) (NOOP)

nothing length() (RT_NOOP)

N

Returns the length in characters for the string passed.

list list(...) (CONST)

N

Returns a list with the argument passed as the first element (or an empty list if no argument is passed)

nothing load_module(string)

nothing load_module() (RT_NOOP)

Y

Loads a Qore module at run-time if the feature name is not already present in the current Program object.

date localtime(date) (CONST)

date localtime(softint, softint = 0) (CONST)

date localtime() (CONST)

N

Returns a date value in localtime; if an argument is passed, then the date is created based on the value of the argument passed, for an integer, it is the number of seconds after Jan 1, 1970, 00:00:00Z (UTC).

float log10(softfloat) (CONST)

float log10() (RT_NOOP)

N

Returns the base 10 logarithm of the value passed

float log1p(softfloat) (CONST)

float log1p() (RT_NOOP)

N

Returns the natural logarithm of the value passed plus 1

float logb(softfloat) (CONST)

float logb() (RT_NOOP)

N

Returns the exponent of a number.

*list lstat(string)

nothing lstat() (RT_NOOP)

N

Returns a list of file status values for the file or symbolic link passed or NOTHING if the call to stat() fails.

string makeBase64String(data) (CONST)

nothing makeBase64String() (RT_NOOP)

N

Returns a base64-encoded representation of a binary object or a string.

string makeHexString(data) (CONST)

nothing makeHexString() (RT_NOOP)

N

Returns a hex-encoded representation of a binary object or a string.

any max(...) (CONST)

any max(list) (CONST)

any max(list, string)

any max(list, code)

N

Returns the maximum value in a list (see also min()); one variant takes an optional callback reference to process lists of complex data types.

string MD2(data)

Y

Returns the MD2 message digest of the supplied argument as a hex string (for string arguments, the trailing null character is not included in the digest)

binary MD2_bin(data)

Y

Returns the MD2 message digest of the supplied argument as a binary object (for strings, the trailing null character is not included in the digest)

string MD4(data)

Y

Returns the MD4 message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)

binary MD4_bin(data)

Y

Returns the MD4 message digest of the supplied argument as a binary object (for strings, the trailing null character is not included in the digest)

string MD5(data)

Y

Returns the MD5 message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)

binary MD5_bin(data)

Y

Returns the MD5 message digest of the supplied argument as a binary object (for strings, the trailing null character is not included in the digest)

string MDC2(data)

Y

Returns the MDC2 message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)

binary MDC2_bin(data)

Y

Returns the MDC2 message digest of the supplied argument as a binary object (for strings, the trailing null character is not included in the digest)

date microseconds(softint) (CONST)

date microseconds() (RT_NOOP)

N

Returns a relative date in microseconds to be used in date arithmetic.

date milliseconds(softint) (CONST)

date milliseconds() (RT_NOOP)

N

Returns a relative date in milliseconds to be used in date arithmetic.

any min(...) (CONST)

any min(list) (CONST)

any min(list, string)

any min(list, code)

N

Returns the minumum value in a list (see also max()); one variant takes an optional closure or call reference to process lists of complex data types.

date minutes(softint) (CONST)

date minutes() (RT_NOOP)

N

Returns a relative date in minutes to be used in date arithmetic.

int mkdir(string, softint = 0777)

Y

Creates a directory with the given mode/permissions.

int mkfifo(string, softint = 0600)

Y

Creates a named pipe with the given mode/permissions.

int mktime(date) (CONST)

nothing mktime() (RT_NOOP)

N

Returns the number of seconds after Jan 1, 1970, 00:00:00Z for the date/time value passed.

date months(softint) (CONST)

date months() (RT_NOOP)

N

Returns a relative date in months to be used in date arithmetic.

float nlog(softfloat) (CONST)

float nlog() (RT_NOOP)

N

Returns the natural logarithm of the value passed

date now() (CONST)

N

Returns current date and time with resolution to the second

date now_ms() (CONST)

N

Returns current date and time with resolution to the millisecond

date now_us() (CONST)

N

Returns current date and time with resolution to the microsecond

date now_utc() (CONST)

N

Returns current UTC date and time with resolution to the microsecond.

int num_threads() (CONST)

N

Returns the current number of threads in the process

int ord(softstring, softint = 0) (CONST)

nothing ord() (RT_NOOP)

N

Gives the numeric value of the character passed

nothing parse(string, string)

nothing parse() (RT_NOOP)

Y

Adds the text passed to the current program's code

hash parse_url(string)

Y

Parses a URL string and returns a hash of the components; throws an exception if the string cannot be parsed as URL.

binary parseBase64String(string)

nothing parseBase64String() (RT_NOOP)

Y

Parses a base64 encoded string and returns the binary object

hash parseDatasource(string)

nothing parseDatasource() (RT_NOOP)

N

Returns a hash of the components of a datasource string (ex: "user/pass@db(encoding)%host:port{min=2,max=4}").

binary parseHexString(string)

nothing parseHexString() (RT_NOOP)

Y

Parses a hex-encoded string and returns the binary object; if invalid hex digits are found an exception is thrown.

*hash parseURL(string)

nothing parseURL() (RT_NOOP)

N

Parses a URL string and returns a hash of the components, unless the string cannot be parsed as URL in which case NOTHING is returned.

float pow(softfloat = 0.0, softfloat = 0.0)

Y

Returns the value of the first argument raised to the power of the second

nothing print(...)

N

Prints the string passed without any formatting.

string printf(string, ...)

string printf() (RT_NOOP)

Y

Prints a formatted string and returns string printed.

int rand()

N

Returns a random integer number.

binary rc2_encrypt_cbc(data, data, data = defaultIV)

Y

Encrypts data using the Cipher Block Chaining function for RSA's RC2(tm) algorithm.

binary rc2_decrypt_cbc(binary, data, data = defaultIV)

Y

Decrypts data using the Cipher Block Chaining function for RSA's RC2(tm) algorithm.

string rc2_decrypt_cbc_to_string(binary, data, data = defaultIV)

Y

Decrypts data to a string using the Cipher Block Chaining function for RSA's RC2(tm) algorithm.

binary rc4_encrypt(data, data, data = defaultIV)

Y

Encrypts data using the Alleged RC4 cipher algorithm, which should be compatible with RSA's RC4(tm) algorithm.

binary rc4_decrypt(binary, data, data = defaultIV)

Y

Decrypts data using the Alleged RC4 cipher algorithm, which should be compatible with RSA's RC4(tm) algorithm.

string rc4_decrypt_to_string(binary, data, data = defaultIV)

Y

Decrypts data to a string using the Alleged RC4 cipher algorithm, which should be compatible with RSA's RC4(tm) algorithm.

binary rc5_encrypt_cbc(data, data, data = defaultIV)

Y

Encrypts data using the Cipher Block Chaining function for RSA's RC5(tm) algorithm.

binary rc5_decrypt_cbc(binary, data, data = defaultIV)

Y

Decrypts data using the Cipher Block Chaining function for RSA's RC5(tm) algorithm.

string rc5_decrypt_cbc_to_string(binary, data, data = defaultIV)

Y

Decrypts data to a string using the Cipher Block Chaining function for RSA's RC5(tm) algorithm.

string readlink(string)

N

Returns the target of a symbolic link; throws an exception if an error occurs.

bool regex(string, string, int = 0)

nothing regex() (RT_NOOP)

Y

Returns true if the regular expression matches the string passed

*list regex_extract(string, string, int = 0)

nothing regex_extract() (RT_NOOP)

Y

Returns a list of substrings in a string based on matching patterns defined by a regular expression.

string regex_subst(string, string, string, int = 0)

nothing regex_subst() (RT_NOOP)

Y

Returns a string with patterns substituted according to the arguments passed.

nothing remove_signal_handler(softint)

N

Removes an installed signal handler and returns the signal handling state to the default.

nothing remove_thread_data(list)

nothing remove_thread_data(...)

N

Removes the listed keys from the thread-local data hash.

nothing rename(string, string)

Y

Renames (or moves) a file or directory.

string replace(string, string, string)

nothing replace() (RT_NOOP)

N

Replaces all occurrances of a substring in a string with another string and returns the new string.

string reverse(string) (CONST)

list reverse(list) (CONST)

nothing reverse() (RT_NOOP)

N

Reverses the order of a string or a list and returns the new string or list.

string RIPEMD160(data)

Y

Returns the RIPEMD160 message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)

binary RIPEMD160_bin(data)

Y

Returns the RIPEMD160 message digest of the supplied argument as a binary object (for strings, the trailing null character is not included in the digest)

int rindex(softstring, softstring, softint = -1) (CONST)

int rindex() (RT_NOOP)

N

Returns the starting character position of a string in another string as searched from the end of the string.

int rmdir(string)

N

Removes a directory.

float round(softfloat) (CONST)

float round() (RT_NOOP)

N

Returns a value rounded up to the nearest integer.

nothing save_thread_data(hash)

nothing save_thread_data(string, any)

nothing save_thread_data() (RT_NOOP)

Y

Saves the data passed against the key passed in thread-local storage.

date seconds(softint) (CONST)

date seconds() (RT_NOOP)

N

Returns a relative date/time value in seconds to be used in date arithmetic.

nothing set_signal_handler(softint, code)

N

Installs or replaces a signal handler.

int setegid(softint)

N

Changes the process effective group ID according to the argument passed. Returns 0 for success, non-zero for errors (the error code can be retrieved with errno())

int seteuid(softint)

N

Changes the process effective user ID according to the argument passed. Returns 0 for success, non-zero for errors (the error code can be retrieved with errno())

int setenv(string, softstring)

nothing setenv() (RT_NOOP)

N

Sets the value of an environment variable

int setgid(softint)

Y

Changes the process group ID according to the argument passed. Returns 0 for success, non-zero for errors (the error code can be retrieved with errno())

int setsid()

Y

Creates a new session lead by the current process.

int setuid(softint)

Y

Changes the process user ID according to the argument passed. Returns 0 for success, non-zero for errors (the error code can be retrieved with errno())

string SHA(data)

Y

Returns the SHA message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)

binary SHA_bin(data)

Y

Returns the SHA message digest of the supplied argument as a binary object(for strings, the trailing null character is not included in the digest)

string SHA1(data)

Y

Returns the SHA1 message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)

binary SHA1_bin(data)

Y

Returns the SHA1 message digest of the supplied argument as a binary object (for strings, the trailing null character is not included in the digest)

string SHA224(data)

Y

Returns the SHA224 message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)

binary SHA224_bin(data)

Y

Returns the SHA224 message digest of the supplied argument as a binary object (for strings, the trailing null character is not included in the digest)

string SHA256(data)

Y

Returns the SHA256 message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)

binary SHA256_bin(data)

Y

Returns the SHA256 message digest of the supplied argument as a binary object (for strings, the trailing null character is not included in the digest)

string SHA384(data)

Y

Returns the SHA384 message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)

binary SHA384_bin(data)

Y

Returns the SHA384 message digest of the supplied argument as a binary object (for strings, the trailing null character is not included in the digest)

string SHA512(data)

Y

Returns the SHA512 message digest of the supplied argument as a hex string (for strings, the trailing null character is not included in the digest)

binary SHA512_bin(data)

Y

Returns the SHA512 message digest of the supplied argument as a binary object (for strings, the trailing null character is not included in the digest)

int sleep(softint)

int sleep(date)

nothing sleep() (RT_NOOP)

N

Causes the current thread to sleep for a certain number of seconds.

list sort(list) (CONST)

list sort(list, code)

list sort(list, string)

nothing sort() (RT_NOOP)

Y

Sorts a list in ascending order (unstable); optionally takes a closure or a call reference (function or object method reference) to sort non-trivial data types.

list sortDescending(list) (CONST)

list sortDescending(list, code)

list sortDescending(list, string)

nothing sortDescending() (RT_NOOP)

Y

Sorts a list in descending order (unstable); optionally takes a closure or call reference (function or object method reference) to sort non-trivial data types.

list sortDescendingStable(list) (CONST)

list sortDescendingStable(list, code)

list sortDescendingStable(list, string)

nothing sortDescendingStable() (RT_NOOP)

Y

Performs a descending stable sort on a list and returns the new list; optionally takes a closure or call reference (function or object method reference) to sort non-trivial data types.

list sortStable(list) (CONST)

list sortStable(list, code)

list sortStable(list, string)

nothing sortStable() (RT_NOOP)

Y

Performs an ascending stable sort on a list and returns the new list; optionally takes a closure or call reference (function or object method reference) to sort non-trivial data types.

list split(string $pattern, string $string, bool $with_pattern = False) (CONST)

list split(string $pattern, string $string, string $quote) (RET_VALUE_ONLY)

list split(binary $pattern, binary $bin) (CONST)

list split() (RT_NOOP)

Y

Splits a string into a list of components based on a separator string and an optional quote.

string sprintf(string, ...) (CONST)

string sprintf() (RT_NOOP)

Y

Creates a string from the format argument passed and the other arguments.

float sin(softfloat) (CONST)

float sin() (RT_NOOP)

N

Returns the sine of the number in radians passed.

float sinh(softfloat) (CONST)

float sinh() (RT_NOOP)

N

Returns the hyperbolic sine of the number passed.

float sqrt(softfloat) (CONST)

float sqrt() (RT_NOOP)

N

Returns the square root of the number passed.

nothing srand(softint)

nothing srand() (RT_NOOP)

N

Seeds the random number generator with the integer passed.

*list stat(string)

nothing stat() (RT_NOOP)

N

Returns a list of file status information for the filename passed or NOTHING if the stat() call fails.

*hash statvfs(string)

Y

Returns a list of filesystem status information for the filename passed or NOTHING if the statvfs() call fails.

string strerror(softint) (CONST)

nothing strerror() (RT_NOOP)

N

Returns the description of the error number passed

string string(softstring) (CONST)

string string(null) (CONST)

string string() (CONST)

N

Returns the argument converted to a string

int strlen(softstring) (CONST)

int strlen(any) (NOOP)

nothing strlen() (RT_NOOP)

N

Returns the number of characters in a string.

string strmul(softstring, int)

string strmul(softstring, int, int)

Y

"Multiplies" the string.

int strtoint(softstring, int = 10) (CONST)

nothing strtoint() (RT_NOOP)

N

Returns an integer corresponding to the string passed with the possibility to specify the base (default base 10).

string substr(softstring, softint, softint) (CONST)

string substr(softstring, softint) (CONST)

nothing substr() (RT_NOOP)

N

Returns a substring of a string

int system(string)

nothing system() (RT_NOOP)

Y

Executes a process and returns the return code

float tan(softfloat) (CONST)

float tan() (RT_NOOP)

N

Returns the tangent of the number in radians passed.

float tanh(softfloat) (CONST)

float tanh() (RT_NOOP)

N

Returns the hyperbolic tangent of the number passed.

list thread_list() (CONST)

N

Returns a list of all current thread IDs

nothing throwThreadResourceExceptions()

Y

Immediately runs all thread resource cleanup routines for the current thread and throws all associated exceptions.

int timegm(date) (CONST)

nothing timegm() (RT_NOOP)

N

Returns the number of seconds since January 1, 1970 00:00:00 in the local time zone for a given date.

string tolower(string) (CONST)

nothing tolower() (RT_NOOP)

N

Converts a string to all lowercase

string toupper(string) (CONST)

nothing toupper() (RT_NOOP)

N

Converts a string to all uppercase

string trim(string, string = "") (CONST)

any trim(reference, string = "")

nothing trim() (RT_NOOP)

N

Removes the characters from a string (whiltespace by default, can be overridden) and returns the new string (also see the trim operator); also accepts an lvalue reference to do modifications in-place.

string type(any) (CONST)

N

Returns the data type of the argument passed (see Type_Constants)

string typename(any) (CONST, DEPRECATED)

N

deprecated: use type() instead

int umask(softint)

nothing umask() (RT_NOOP)

N

Sets the file creation mask for the process

binary uncompress_to_binary(binary)

nothing uncompress_to_binary() (RT_NOOP)

Y

Uncompresses (inflates) data compressed with the "deflate" algorithm (RFC 1951) using zlib functions and returns a binary object.

string uncompress_to_string(binary)

string uncompress_to_string(binary, string)

nothing uncompress_to_string() (RT_NOOP)

Y

Uncompresses (inflates) data compressed with the "deflate" algorithm (RFC 1951) using zlib functions and returns a string.

int unlink(string)

nothing unlink() (RT_NOOP)

N

Deletes a file and returns 0 for success.

int unsetenv(string)

nothing unsetenv() (RT_NOOP)

N

Unsets an environment variable

int usleep(date)

int usleep(softint)

nothing usleep() (RT_NOOP)

N

Causes the current thread to sleep for a certain number of microseconds

string vprintf(string, any)

string vprintf() (RT_NOOP)

Y

Outputs a formatted string based on a variable number of arguments given in a list after the format string. Returns the string printed.

string vsprintf(string, any)

string vsprintf() (RT_NOOP)

Y

Formats a string based on a variable number of arguments given in a list after the format string and returns this formatted string.

date years(softint) (CONST)

date years() (RT_NOOP)

N

Returns a relative date/time value in years to be used in date arithmetic.


3.1. Math Functions

3.1.1. abs()

Synopsis

Returns the absolute value of the argument passed.

Prototype

float abs(softfloat)

int abs(int)

float abs() (RT_NOOP)

Example
$x = abs($y);

Table 3.4. Arguments and Return Values for abs()

Argument Type

Return Type

Description

int

int

Absolute value of the integer passed.

softfloat

float

Absolute value of the floating-point value passed.


This function does not throw any exceptions.

3.1.2. acos()

Synopsis

Returns the arc cosine of the number passed in radians

Prototype

float acos(any)

Example
$x = acos($y);

Table 3.5. Arguments and Return Values for acos()

Argument Type

Return Type

Description

any

float

Returns the arc cosine of the value passed convert to a float in radians.


This function does not throw any exceptions.

3.1.3. asin()

Synopsis

Returns the arc sine of the number passed in radians

Prototype

float asin(softfloat)

float asin() (RT_NOOP)

Example
$x = asin($y);

Table 3.6. Arguments and Return Values for asin()

Argument Type

Return Type

Description

softfloat

float

Returns the arc sine of the number passed in radians.


This function does not throw any exceptions.

3.1.4. atan()

Synopsis

Returns the arc tangent of the number passed in radians

Prototype

float atan(softfloat)

float atan() (RT_NOOP)

Example
$x = atan($y);

Table 3.7. Arguments and Return Values for atan()

Argument Type

Return Type

Description

softfloat

float

Returns the arc tangent of the number passed in radians.


This function does not throw any exceptions.

3.1.5. cbrt()

Synopsis

Returns the cube root of the number passed.

Prototype

float cbrt(softfloat)

float cbrt() (RT_NOOP)

Example
$x = cbrt($y);

Table 3.8. Arguments and Return Values for cbrt()

Argument Type

Return Type

Description

softfloat

float

Returns the cube root of the number passed.


This function does not throw any exceptions.

3.1.6. ceil()

Synopsis

Returns a floating-point number equal to the smallest integral value greater than or equal to the argument passed.

Prototype

float ceil(softfloat)

float ceil() (RT_NOOP)

Example
$x = ceil(3.2); # will return 4.0 

Table 3.9. Arguments and Return Values for ceil()

Argument Type

Return Type

Description

softfloat

float

Returns a value rounded up to the nearest integral floating-point value.


This function does not throw any exceptions.

3.1.7. cos()

Synopsis

Returns the cosine of the number in radians passed.

Prototype

float cos(softfloat) (CONST)

float cos() (RT_NOOP)

Example
$x = cos($y);

Table 3.10. Arguments and Return Values for cos()

Argument Type

Return Type

Description

softfloat

float

Returns the cosine of the number in radians passed.


This function does not throw any exceptions.

3.1.8. cosh()

Synopsis

Returns the hyperbolic cosine of the number in radians passed.

Prototype

float cosh(softfloat) (CONST)

float cosh() (RT_NOOP)

Example
$x = cosh($y);

Table 3.11. Arguments and Return Values for cosh()

Argument Type

Return Type

Description

softfloat

float

Returns the hyperbolic cosine of the number in radians passed.


This function does not throw any exceptions.

3.1.9. exp()

Synopsis

Returns the value of e raised to the power of the argument passed.

Prototype

float exp(softfloat) (CONST)

float exp() (RT_NOOP)

Example
$x = exp($y);

Table 3.12. Arguments and Return Values for exp()

Argument Type

Return Type

Description

softfloat

float

Returns the value of e raised to the power of the argument passed.


This function does not throw any exceptions.

3.1.10. exp2()

Synopsis

Returns the value of 2 raised to the power of the argument passed.

Prototype

float exp2(softfloat) (CONST)

float exp2() (RT_NOOP)

Example
$x = exp2($y);

Table 3.13. Arguments and Return Values for exp2()

Argument Type

Return Type

Description

softfloat

float

Returns the value of 2 raised to the power of the argument passed.


This function does not throw any exceptions.

3.1.11. expm1()

Synopsis

Returns an equivalent of exp(x) - 1.

Prototype

float expm1(softfloat) (CONST)

float expm1() (RT_NOOP)

Example
$x = expm1($y);

Table 3.14. Arguments and Return Values for expm1()

Argument Type

Return Type

Description

softfloat

float

Returns an equivalent of exp(x) - 1.


This function does not throw any exceptions.

3.1.12. floor()

Synopsis

Returns a floating-point value rounded down to the integral value.

Prototype

float floor(softfloat) (CONST)

float floor() (RT_NOOP)

Example
$x = floor(3.7); # will return 3.0

Table 3.15. Arguments and Return Values for floor()

Argument Type

Return Type

Description

softfloat

float

Returns a float-point value rounded down to the integral value.


This function does not throw any exceptions.

3.1.13. format_number()

Synopsis

Returns a string of a formatted number according to the arguments passed.

Prototype

string format_number(string, any) (CONST)

nothing format_number() (RT_NOOP)

Description

The format_string has the following format: <thousands_separator>[<decimal_separator><decimals>], where thousands_separator and decimal_separator are single ASCII characters defining the thousands and decimal separator characters respectively, and decimals is a single digit defining how may decimals should appear after the decimal point.

Example
format_number(".,3", -48392093894.2349); # returns "-48.392.093.894,235"

Table 3.16. Arguments and Return Values for format_number()

Argument Types

Return Type

Description

string, any

string

Returns a string corresponding to a number according to the formatting string passed.


This function does not throw any exceptions.

3.1.14. hypot()

Synopsis

Returns the length of the hypotenuse of a right-angle triangle with sides given as the two arguments.

Prototype

float hypot(any $x, softfloat $y) (CONST)

float hypot(softfloat $x, any $y) (CONST)

float hypot() (RT_NOOP)

Example
$z = hypot($x, $y);

Table 3.17. Arguments and Return Values for hypot()

Argument Type

Return Type

Description

softfloat

float

Returns the length of the hypotenuse of a right-angle triangle with sides given as the two arguments.


This function does not throw any exceptions.

3.1.15. log10()

Synopsis

Returns the base 10 logarithm of the value passed.

Prototype

float log10(softfloat) (CONST)

float log10() (RT_NOOP)

Example
$x = log10($y);

Table 3.18. Arguments and Return Values for log10()

Argument Type

Return Type

Description

softfloat

float

Returns the base 10 logarithm of the value passed.


This function does not throw any exceptions.

3.1.16. log1p()

Synopsis

Returns the natural logarithm of the value passed plus 1.

Prototype

float log1p(softfloat) (CONST)

float log1p() (RT_NOOP)

Example
$x = log1p($y);

Table 3.19. Arguments and Return Values for log1p()

Argument Type

Return Type

Description

softfloat

float

Returns the natural logarithm of the value passed plus 1.


This function does not throw any exceptions.

3.1.17. logb()

Synopsis

Returns the exponent of a number.

Prototype

float logb(softfloat) (CONST)

float logb() (RT_NOOP)

Example
$x = logb($y);

Table 3.20. Arguments and Return Values for logb()

Argument Type

Return Type

Description

softfloat

float

Returns the exponent of a number.


This function does not throw any exceptions.

3.1.18. nlog()

Synopsis

Returns the natural logarithm of the value passed.

Prototype

float nlog(softfloat) (CONST)

float nlog() (RT_NOOP)

Example
$x = nlog();

Table 3.21. Arguments and Return Values for nlog()

Argument Type

Return Type

Description

softfloat

float

Returns the natural logarithm of the value passed.


This function does not throw any exceptions.

3.1.19. pow()

Synopsis

Returns a number raised to the power of another number.

Prototype

float pow(softfloat $x = 0.0, softfloat $y = 0.0)

Example
$z = pow($x, $y);

Table 3.22. Arguments and Return Values for pow()

Argument Types

Return Type

Description

softfloat $x

softfloat $y

Returns x raised to the power of y.


Table 3.23. Exceptions Thrown by pow()

err

desc

DIVISION-BY-ZERO

pow(x, y): y must be a non-negative value.

INVALID-POW-ARGUMENTS

pow(x, y): x cannot be negative when y is not an integer value.


3.1.20. round()

Synopsis

Returns a floating-point number equal to the closest integer to the argument passed. Numbers halfway between two integers are arounded away from zero.

Prototype

float round(softfloat) (CONST)

float round() (RT_NOOP)

Example
$x = round(3.2); # returns 3.0 
Platform Availability

HAVE_ROUND

Table 3.24. Arguments and Return Values for round()

Argument Type

Return Type

Description

softfloat

float

Returns a value rounded to the nearest integral floating-point value, half-way cases are rounded away from zero.


Table 3.25. Exceptions Thrown by round()

err

desc

MISSING-FEATURE-ERROR

This exception is thrown when the function is not available; for maximum portability, check the constant HAVE_ROUND before calling this function.


3.1.21. sin()

Synopsis

Returns the sine of the number in radians passed.

Prototype

float sin(softfloat) (CONST)

float sin() (RT_NOOP)

Example
$x = sin($y);

Table 3.26. Arguments and Return Values for sin()

Argument Type

Return Type

Description

softfloat

float

Returns the sine of the number in radians passed.


This function does not throw any exceptions.

3.1.22. sinh()

Synopsis

Returns the hyperbolic sine of the number in radians passed.

Prototype

float sinh(softfloat) (CONST)

float sinh() (RT_NOOP)

Example
$x = sinh($y);

Table 3.27. Arguments and Return Values for sinh()

Argument Type

Return Type

Description

softfloat

float

Returns the hyperbolic sine of the number in radians passed.


This function does not throw any exceptions.

3.1.23. sqrt()

Synopsis

Returns the square root of the number passed.

Prototype

float sqrt(softfloat) (CONST)

float sqrt() (RT_NOOP)

Example
$x = sqrt($y);

Table 3.28. Arguments and Return Values for sqrt()

Argument Type

Return Type

Description

softfloat

float

Returns the square root of the number passed.


This function does not throw any exceptions.

3.1.24. tan()

Synopsis

Returns the tangent of the number in radians passed.

Prototype

float tan(softfloat) (CONST)

float tan() (RT_NOOP)

Example
$x = tan($y);

Table 3.29. Arguments and Return Values for tan()

Argument Type

Return Type

Description

softfloat

float

Returns the tangent of the number in radians passed.


This function does not throw any exceptions.

3.1.25. tanh()

Synopsis

Returns the hyperbolic tangent of the number in radians passed.

Prototype

float tanh(softfloat) (CONST)

float tanh() (RT_NOOP)

Example
$x = tanh($y);

Table 3.30. Arguments and Return Values for tanh()

Argument Type

Return Type

Description

softfloat

float

Returns the hyperbolic tangent of the number in radians passed.


This function does not throw any exceptions.