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

nothingabort()

N

aborts the process

floatabs(softfloat)

intabs(int)

floatabs() (RT_NOOP)

N

Returns the absolute value of the argument passed

floatacos(any)

N

Returns the arc cosine of the number passed in radians

floatasin(softfloat)

floatasin() (RT_NOOP)

N

Returns the arc sine of the number passed in radians.

floatatan(softfloat)

floatatan() (RT_NOOP)

N

Returns the arc tangent of the number passed in radians.

stringbackquote(string)

nothingbackquote() (RT_NOOP)

Y

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

stringbasename(string)

nothingbasename() (RT_NOOP)

N

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

binarybinary(softstring) (CONST)

binarybinary(binary) (CONST)

binarybinary(null) (CONST)

binarybinary() (CONST)

N

Returns a binary data type of the data passed.

stringbinary_to_string(binary)

stringbinary_to_string(binary, string)

Y

Returns a string created from the binary data passed.

intbindex(softstring, softstring, softint = 0)

intbindex() (RT_NOOP)

N

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

binaryblowfish_encrypt_cbc(data, data, data = defaultIV)

Y

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

binaryblowfish_decrypt_cbc(binary, data, data = defaultIV)

Y

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

stringblowfish_decrypt_cbc_to_string(binary, data, data = defaultIV)

Y

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

boolboolean(softbool) (CONST)

boolboolean(null) (CONST)

boolboolean() (CONST)

N

Converts the argument to a boolean value.

intbrindex(softstring, softstring, softint = -1)

intbrindex() (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

binarybunzip2_to_binary(binary)

nothingbunzip2_to_binary() (RT_NOOP)

Y

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

stringbunzip2_to_string(binary, string = defaultEncoding)

nothingbunzip2_to_string() (RT_NOOP)

Y

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

binarybzip2(data, softint = 9)

nothingbzip2() (RT_NOOP)

Y

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

anycall_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

anycall_builtin_function_args(string, list)

anycall_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.

anycall_function(string, ...)

anycall_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).

anycall_function_args(string, list)

anycall_function_args(string, any)

anycall_function_args(code, list)

anycall_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.

anycallObjectMethod(object, string)

nothingcallObjectMethod() (RT_NOOP)

Y

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

anycallObjectMethodArgs(object, string, list)

anycallObjectMethodArgs(object, string, any)

nothingcallObjectMethodArgs() (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

binarycast5_encrypt_cbc(data, data, data = defaultIV)

Y

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

binarycast5_decrypt_cbc(binary, data, data = defaultIV)

Y

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

stringcast5_decrypt_cbc_to_string(binary, data, data = defaultIV)

Y

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

floatcbrt(softfloat)

floatcbrt() (RT_NOOP)

N

Returns the cube root of the number passed.

floatceil(softfloat)

floatceil() (RT_NOOP)

N

Returns a value rounded up to the next highest integer

intchdir(string)

Y

Changes the current working directory.

intchmod(string, int)

Y

Changes the mode of a file.

stringchomp(string)

anychomp(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.

intchown(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.

stringchr(softint)

stringchr(any) (NOOP)

nothingchr() (RT_NOOP)

N

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

intclock_getmicros() (CONST)

N

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

intclock_getmillis() (CONST)

N

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

intclock_getnanos() (CONST)

N

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

binarycompress(data, softint = -1)

nothingcompress() (RT_NOOP)

Y

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

stringconvert_encoding(string, string) (CONST)

nothingconvert_encoding() (RT_NOOP)

Y

Performs explicit string character encoding conversions.

floatcos(softfloat) (CONST)

floatcos() (RT_NOOP)

N

Returns the cosine of the number in radians passed.

floatcosh(softfloat) (CONST)

floatcosh() (RT_NOOP)

N

Returns the hyperbolic cosine of the number passed.

datedate(string) (CONST)

datedate(string, string) (CONST)

datedate(softint) (CONST)

datedate(null) (CONST)

datedate() (CONST)

N

Converts the argument passed to a date.

hashdate_info(date$date) (CONST)

hashdate_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.

datedate_ms(softint) (CONST)

datedate_ms() (RT_NOOP)

N

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

datedate_us(softint) (CONST)

datedate_us() (RT_NOOP)

N

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

datedays(softint) (CONST)

datedays() (RT_NOOP)

N

Returns a relative date in days for date arithmetic.

stringdecode_url(string) (CONST)

nothingdecode_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.

nothingdelete_thread_data(list)

nothingdelete_thread_data(...)

N

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

binarydes_encrypt_cbc(data, data, data = defaultIV)

Y

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

binarydes_decrypt_cbc(binary, data, data = defaultIV)

Y

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

stringdes_decrypt_cbc_to_string(binary, data, data = defaultIV)

Y

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

binarydes_ede_encrypt_cbc(data, data, data = defaultIV)

Y

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

binarydes_ede_decrypt_cbc(binary, data, data = defaultIV)

Y

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

stringdes_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.

binarydes_ede3_encrypt_cbc(data, data, data = defaultIV)

Y

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

binarydes_ede3_decrypt_cbc(binary, data, data = defaultIV)

Y

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

stringdes_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.

binarydesx_encrypt_cbc(data, data, data = defaultIV)

Y

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

binarydesx_decrypt_cbc(binary, data, data = defaultIV)

Y

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

stringdesx_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.

stringDSS(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)

binaryDSS_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)

stringDSS1(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)

binaryDSS1_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)

interrno()

N

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

nothingexec(string)

nothingexec() (RT_NOOP)

N

Replaces the current process image with another.

boolexistsFunction(string) (CONST)

boolexistsFunction(code) (NOOP)

nothingexistsFunction() (RT_NOOP)

N

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

nothingexit(any = 0)

N

Exits the program

floatexp(softfloat) (CONST)

floatexp() (RT_NOOP)

N

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

floatexp2(softfloat) (CONST)

floatexp2() (RT_NOOP)

N

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

floatexpm1(softfloat) (CONST)

floatexpm1() (RT_NOOP)

N

Returns an equivalent of exp(x) - 1

stringf_printf(string, ...)

stringf_printf() (RT_NOOP)

Y

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

stringf_sprintf(string, ...) (CONST)

stringf_sprintf() (RT_NOOP)

Y

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

floatfloat(softfloat) (CONST)

floatfloat(null) (CONST)

floatfloat() (CONST)

N

Returns the argument converted to a floating-point number

floatfloor(softfloat) (CONST)

floatfloor() (RT_NOOP)

N

Returns a value rounded down to the nearest integer

nothingflush()

N

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

stringforce_encoding(string, string) (CONST)

nothingforce_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.

intfork()

Y

Creates a duplicate of the current process

stringformat_date(string, date) (CONST)

nothingformat_date() (RT_NOOP)

N

Allows dates to be formatted

stringformat_number(string, any) (CONST)

nothingformat_number() (RT_NOOP)

N

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

*stringfunctionType(string) (CONST)

nothingfunctionType() (RT_NOOP)

N

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

hashget_all_thread_data() (CONST)

N

Returns the entire thread data hash.

*intget_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.

intget_days(date) (CONST)

nothingget_days() (RT_NOOP)

N

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

stringget_default_encoding() (CONST)

N

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

intget_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.

intget_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.

intget_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.

stringget_encoding(string) (CONST)

nothingget_encoding() (RT_NOOP)

N

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

intget_epoch_seconds(date) (CONST)

nothingget_epoch_seconds() (RT_NOOP)

N

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

intget_hours(date) (CONST)

nothingget_hours() (RT_NOOP)

N

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

intget_microseconds(date) (CONST)

N

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

dateget_midnight(date) (CONST)

nothingget_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)

intget_milliseconds(date) (CONST)

nothingget_milliseconds() (RT_NOOP)

N

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

intget_minutes(date) (CONST)

nothingget_minutes() (RT_NOOP)

N

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

intget_months(date) (CONST)

nothingget_months() (RT_NOOP)

N

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

hashget_qore_library_info() (CONST)

N

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

listget_qore_option_list() (CONST)

N

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

intget_seconds(date) (CONST)

nothingget_seconds() (RT_NOOP)

N

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

*stringget_script_path() (CONST)

N

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

*stringget_script_dir() (CONST)

N

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

*stringget_script_name() (CONST)

N

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

anyget_thread_data(string) (CONST)

nothingget_thread_data() (RT_NOOP)

N

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

*intget_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.

*intget_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.

*intget_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..

*intget_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..

intget_years(date) (CONST)

nothingget_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

listgetaddrinfo(*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.

hashgetAllThreadCallStacks()

N

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

*intgetByte(data, softint = 0) (CONST)

nothinggetByte() (RT_NOOP)

N

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

stringgetClassName(object) (CONST)

nothinggetClassName() (RT_NOOP)

N

Returns the class name of the object passed.

*stringgetcwd()

N

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

stringgetcwd2()

Y

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

dategetDateFromISOWeek(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.

intgetDayOfWeek(date) (CONST)

nothinggetDayOfWeek() (RT_NOOP)

N

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

intgetDayNumber(date) (CONST)

nothinggetDayNumber() (RT_NOOP)

N

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

*listgetDBIDriverCapabilities(string)

nothinggetDBIDriverCapabilities() (RT_NOOP)

N

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

*listgetDBIDriverCapabilityList(string)

nothinggetDBIDriverCapabilityList() (RT_NOOP)

N

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

*listgetDBIDriverList()

N

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

intgetegid() (CONST)

Y

Returns the effective group ID of the current process.

intgeteuid() (CONST)

Y

Returns the effective user ID of the current process.

listgetFeatureList() (CONST)

N

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

*stringgetenv(string) (CONST)

nothinggetenv() (RT_NOOP)

N

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

intgetgid(CONST)

Y

Returns the real group ID of the current process.

*hashgetgrnam(string) (CONST)

Y

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

hashgetgrnam2(string)

Y

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

*hashgetgrgid(softint) (CONST)

Y

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

hashgetgrgid2(softint)

Y

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

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

nothinggethostbyaddr() (RT_NOOP)

N

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

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

nothinggethostbyaddr_long() (RT_NOOP)

N

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

*stringgethostbyname(string) (CONST)

nothinggethostbyname() (RT_NOOP)

N

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

*hashgethostbyname_long(string) (CONST)

N

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

stringgethostname()

Y

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

intgetISODayOfWeek(date) (CONST)

nothinggetISODayOfWeek() (RT_NOOP)

N

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

hashgetISOWeekHash(date) (CONST)

nothinggetISOWeekHash() (RT_NOOP)

N

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

stringgetISOWeekString(date) (CONST)

nothinggetISOWeekString() (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")

listgetMethodList(object) (CONST)

nothinggetMethodList() (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).

hashgetModuleHash() (CONST)

N

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

listgetModuleList() (CONST)

N

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

intgetpid() (CONST)

N

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

intgetppid() (CONST)

Y

Returns the parent PID of the current process.

*hashgetpwnam(string) (CONST)

Y

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

hashgetpwnam2(string)

Y

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

*hashgetpwuid(softint) (CONST)

Y

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

hashgetpwuid2(softint)

N

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

intgettid() (CONST)

N

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

intgetuid() (CONST)

Y

Returns the real user ID of the current process.

anygetWord32(string, int = 0) (CONST)

anygetWord32(binary, int = 0) (CONST)

nothinggetWord32() (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.

*listglob(string)

nothingglob() (RT_NOOP)

N

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

dategmtime(date) (CONST)

dategmtime(softint, softint = 0) (CONST)

dategmtime() (CONST)

N

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

binarygunzip_to_binary(binary)

nothinggunzip_to_binary() (RT_NOOP)

Y

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

stringgunzip_to_string(binary)

stringgunzip_to_string(binary, string)

nothinggunzip_to_string() (RT_NOOP)

Y

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

binarygzip(string, softint = -1)

binarygzip(binary, softint = -1)

nothinggzip() (RT_NOOP)

Y

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

boolhas_key(hash$hash, string$key) (RET_VALUE_ONLY)

boolhas_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.

hashhash(list$list)

hashhash(list$keys, list$values)

hashhash(hash$hash) (CONST)

hashhash(object$obj)

hashhash() (CONST)

N

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

listhash_values(hash) (CONST)

nothinghash_values() (RT_NOOP)

N

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

inthextoint(string)

Y

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

*hashhlstat(string)

nothinghlstat() (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.

datehours(softint) (CONST)

datehours() (RT_NOOP)

N

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

*hashhstat(string)

nothinghstat() (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.

stringhtml_decode(string) (CONST)

nothinghtml_decode() (RT_NOOP)

N

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

stringhtml_encode(string) (CONST)

nothinghtml_encode() (RT_NOOP)

N

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

floathypot(any, softfloat) (CONST)

floathypot(softfloat, any) (CONST)

floathypot() (RT_NOOP)

N

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

intindex(softstring, softstring, softint = 0) (CONST)

intindex() (RT_NOOP)

N

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

boolinlist(any, list)

boolinlist(any, any)

boolinlist() (RT_NOOP)

N

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

boolinlist_hard(any, list)

boolinlist_hard(any, any)

N

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

intint(softint) (CONST)

intint(null) (CONST)

intint() (CONST)

N

Returns the argument converted to an integer

boolis_bdev(string) (CONST)

N

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

boolis_cdev(string) (CONST)

N

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

boolis_date_absolute(date) (CONST)

boolis_date_absolute(any) (RT_NOOP)

N

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

boolis_date_relative(date) (CONST)

boolis_date_relative(any) (RT_NOOP)

N

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

boolis_dev(string) (CONST)

N

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

boolis_dir(string) (CONST)

N

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

boolis_executable(string) (CONST)

Y

Returns True if the string passed identifies an executable file.

boolis_file(string) (CONST)

N

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

boolis_link(string) (CONST)

Y

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

boolis_pipe(string) (CONST)

N

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

boolis_readable(string) (CONST)

N

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

boolis_socket(string) (CONST)

Y

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

boolis_writeable(string) (CONST)

N

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

stringjoin(string, list) (CONST)

stringjoin(string, ...) (CONST)

nothingjoin() (RT_NOOP)

N

Creates a string from a list and separator character

intkill(softint, softint = SIGHUP)

nothingkill() (RT_NOOP)

Y

Sends a signal to a process (default: SIGHUP)

intlchown(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.

intlength(softstring) (CONST)

intlength(binary) (CONST)

intlength(any) (NOOP)

nothinglength() (RT_NOOP)

N

Returns the length in characters for the string passed.

listlist(...) (CONST)

N

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

nothingload_module(string)

nothingload_module() (RT_NOOP)

Y

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

datelocaltime(date) (CONST)

datelocaltime(softint, softint = 0) (CONST)

datelocaltime() (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).

floatlog10(softfloat) (CONST)

floatlog10() (RT_NOOP)

N

Returns the base 10 logarithm of the value passed

floatlog1p(softfloat) (CONST)

floatlog1p() (RT_NOOP)

N

Returns the natural logarithm of the value passed plus 1

floatlogb(softfloat) (CONST)

floatlogb() (RT_NOOP)

N

Returns the exponent of a number.

*listlstat(string)

nothinglstat() (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.

stringmakeBase64String(data) (CONST)

nothingmakeBase64String() (RT_NOOP)

N

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

stringmakeHexString(data) (CONST)

nothingmakeHexString() (RT_NOOP)

N

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

anymax(...) (CONST)

anymax(list) (CONST)

anymax(list, string)

anymax(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.

stringMD2(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)

binaryMD2_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)

stringMD4(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)

binaryMD4_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)

stringMD5(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)

binaryMD5_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)

stringMDC2(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)

binaryMDC2_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)

datemicroseconds(softint) (CONST)

datemicroseconds() (RT_NOOP)

N

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

datemilliseconds(softint) (CONST)

datemilliseconds() (RT_NOOP)

N

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

anymin(...) (CONST)

anymin(list) (CONST)

anymin(list, string)

anymin(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.

dateminutes(softint) (CONST)

dateminutes() (RT_NOOP)

N

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

intmkdir(string, softint = 0777)

Y

Creates a directory with the given mode/permissions.

intmkfifo(string, softint = 0600)

Y

Creates a named pipe with the given mode/permissions.

intmktime(date) (CONST)

nothingmktime() (RT_NOOP)

N

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

datemonths(softint) (CONST)

datemonths() (RT_NOOP)

N

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

floatnlog(softfloat) (CONST)

floatnlog() (RT_NOOP)

N

Returns the natural logarithm of the value passed

datenow() (CONST)

N

Returns current date and time with resolution to the second

datenow_ms() (CONST)

N

Returns current date and time with resolution to the millisecond

datenow_us() (CONST)

N

Returns current date and time with resolution to the microsecond

datenow_utc() (CONST)

N

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

intnum_threads() (CONST)

N

Returns the current number of threads in the process

intord(softstring, softint = 0) (CONST)

nothingord() (RT_NOOP)

N

Gives the numeric value of the character passed

nothingparse(string, string)

nothingparse() (RT_NOOP)

Y

Adds the text passed to the current program's code

hashparse_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.

binaryparseBase64String(string)

nothingparseBase64String() (RT_NOOP)

Y

Parses a base64 encoded string and returns the binary object

hashparseDatasource(string)

nothingparseDatasource() (RT_NOOP)

N

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

binaryparseHexString(string)

nothingparseHexString() (RT_NOOP)

Y

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

*hashparseURL(string)

nothingparseURL() (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.

floatpow(softfloat = 0.0, softfloat = 0.0)

Y

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

nothingprint(...)

N

Prints the string passed without any formatting.

stringprintf(string, ...)

stringprintf() (RT_NOOP)

Y

Prints a formatted string and returns string printed.

intrand()

N

Returns a random integer number.

binaryrc2_encrypt_cbc(data, data, data = defaultIV)

Y

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

binaryrc2_decrypt_cbc(binary, data, data = defaultIV)

Y

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

stringrc2_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.

binaryrc4_encrypt(data, data, data = defaultIV)

Y

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

binaryrc4_decrypt(binary, data, data = defaultIV)

Y

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

stringrc4_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.

binaryrc5_encrypt_cbc(data, data, data = defaultIV)

Y

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

binaryrc5_decrypt_cbc(binary, data, data = defaultIV)

Y

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

stringrc5_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.

stringreadlink(string)

N

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

boolregex(string, string, int = 0)

nothingregex() (RT_NOOP)

Y

Returns true if the regular expression matches the string passed

*listregex_extract(string, string, int = 0)

nothingregex_extract() (RT_NOOP)

Y

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

stringregex_subst(string, string, string, int = 0)

nothingregex_subst() (RT_NOOP)

Y

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

nothingremove_signal_handler(softint)

N

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

nothingremove_thread_data(list)

nothingremove_thread_data(...)

N

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

nothingrename(string, string)

Y

Renames (or moves) a file or directory.

stringreplace(string, string, string)

nothingreplace() (RT_NOOP)

N

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

stringreverse(string) (CONST)

listreverse(list) (CONST)

nothingreverse() (RT_NOOP)

N

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

stringRIPEMD160(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)

binaryRIPEMD160_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)

intrindex(softstring, softstring, softint = -1) (CONST)

intrindex() (RT_NOOP)

N

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

intrmdir(string)

N

Removes a directory.

floatround(softfloat) (CONST)

floatround() (RT_NOOP)

N

Returns a value rounded up to the nearest integer.

nothingsave_thread_data(hash)

nothingsave_thread_data(string, any)

nothingsave_thread_data() (RT_NOOP)

Y

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

dateseconds(softint) (CONST)

dateseconds() (RT_NOOP)

N

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

nothingset_signal_handler(softint, code)

N

Installs or replaces a signal handler.

intsetegid(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())

intseteuid(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())

intsetenv(string, softstring)

nothingsetenv() (RT_NOOP)

N

Sets the value of an environment variable

intsetgid(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())

intsetsid()

Y

Creates a new session lead by the current process.

intsetuid(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())

stringSHA(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)

binarySHA_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)

stringSHA1(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)

binarySHA1_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)

stringSHA224(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)

binarySHA224_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)

stringSHA256(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)

binarySHA256_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)

stringSHA384(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)

binarySHA384_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)

stringSHA512(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)

binarySHA512_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)

intsleep(softint)

intsleep(date)

nothingsleep() (RT_NOOP)

N

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

listsort(list) (CONST)

listsort(list, code)

listsort(list, string)

nothingsort() (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.

listsortDescending(list) (CONST)

listsortDescending(list, code)

listsortDescending(list, string)

nothingsortDescending() (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.

listsortDescendingStable(list) (CONST)

listsortDescendingStable(list, code)

listsortDescendingStable(list, string)

nothingsortDescendingStable() (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.

listsortStable(list) (CONST)

listsortStable(list, code)

listsortStable(list, string)

nothingsortStable() (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.

listsplit(string$pattern, string$string, bool$with_pattern = False) (CONST)

listsplit(string$pattern, string$string, string$quote) (RET_VALUE_ONLY)

listsplit(binary$pattern, binary$bin) (CONST)

listsplit() (RT_NOOP)

Y

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

stringsprintf(string, ...) (CONST)

stringsprintf() (RT_NOOP)

Y

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

floatsin(softfloat) (CONST)

floatsin() (RT_NOOP)

N

Returns the sine of the number in radians passed.

floatsinh(softfloat) (CONST)

floatsinh() (RT_NOOP)

N

Returns the hyperbolic sine of the number passed.

floatsqrt(softfloat) (CONST)

floatsqrt() (RT_NOOP)

N

Returns the square root of the number passed.

nothingsrand(softint)

nothingsrand() (RT_NOOP)

N

Seeds the random number generator with the integer passed.

*liststat(string)

nothingstat() (RT_NOOP)

N

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

*hashstatvfs(string)

Y

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

stringstrerror(softint) (CONST)

nothingstrerror() (RT_NOOP)

N

Returns the description of the error number passed

stringstring(softstring) (CONST)

stringstring(null) (CONST)

stringstring() (CONST)

N

Returns the argument converted to a string

intstrlen(softstring) (CONST)

intstrlen(any) (NOOP)

nothingstrlen() (RT_NOOP)

N

Returns the number of characters in a string.

stringstrmul(softstring, int)

stringstrmul(softstring, int, int)

Y

"Multiplies" the string.

intstrtoint(softstring, int = 10) (CONST)

nothingstrtoint() (RT_NOOP)

N

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

stringsubstr(softstring, softint, softint) (CONST)

stringsubstr(softstring, softint) (CONST)

nothingsubstr() (RT_NOOP)

N

Returns a substring of a string

intsystem(string)

nothingsystem() (RT_NOOP)

Y

Executes a process and returns the return code

floattan(softfloat) (CONST)

floattan() (RT_NOOP)

N

Returns the tangent of the number in radians passed.

floattanh(softfloat) (CONST)

floattanh() (RT_NOOP)

N

Returns the hyperbolic tangent of the number passed.

listthread_list() (CONST)

N

Returns a list of all current thread IDs

nothingthrowThreadResourceExceptions()

Y

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

inttimegm(date) (CONST)

nothingtimegm() (RT_NOOP)

N

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

stringtolower(string) (CONST)

nothingtolower() (RT_NOOP)

N

Converts a string to all lowercase

stringtoupper(string) (CONST)

nothingtoupper() (RT_NOOP)

N

Converts a string to all uppercase

stringtrim(string, string = "") (CONST)

anytrim(reference, string = "")

nothingtrim() (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.

stringtype(any) (CONST)

N

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

stringtypename(any) (CONST, DEPRECATED)

N

deprecated: use type() instead

intumask(softint)

nothingumask() (RT_NOOP)

N

Sets the file creation mask for the process

binaryuncompress_to_binary(binary)

nothinguncompress_to_binary() (RT_NOOP)

Y

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

stringuncompress_to_string(binary)

stringuncompress_to_string(binary, string)

nothinguncompress_to_string() (RT_NOOP)

Y

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

intunlink(string)

nothingunlink() (RT_NOOP)

N

Deletes a file and returns 0 for success.

intunsetenv(string)

nothingunsetenv() (RT_NOOP)

N

Unsets an environment variable

intusleep(date)

intusleep(softint)

nothingusleep() (RT_NOOP)

N

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

stringvprintf(string, any)

stringvprintf() (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.

stringvsprintf(string, any)

stringvsprintf() (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.

dateyears(softint) (CONST)

dateyears() (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

floatabs(softfloat)

intabs(int)

floatabs() (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

floatacos(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

floatasin(softfloat)

floatasin() (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

floatatan(softfloat)

floatatan() (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

floatcbrt(softfloat)

floatcbrt() (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

floatceil(softfloat)

floatceil() (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

floatcos(softfloat) (CONST)

floatcos() (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

floatcosh(softfloat) (CONST)

floatcosh() (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

floatexp(softfloat) (CONST)

floatexp() (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

floatexp2(softfloat) (CONST)

floatexp2() (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

floatexpm1(softfloat) (CONST)

floatexpm1() (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

floatfloor(softfloat) (CONST)

floatfloor() (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

stringformat_number(string, any) (CONST)

nothingformat_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

floathypot(any$x, softfloat$y) (CONST)

floathypot(softfloat$x, any$y) (CONST)

floathypot() (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

floatlog10(softfloat) (CONST)

floatlog10() (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

floatlog1p(softfloat) (CONST)

floatlog1p() (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

floatlogb(softfloat) (CONST)

floatlogb() (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

floatnlog(softfloat) (CONST)

floatnlog() (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

floatpow(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

floatround(softfloat) (CONST)

floatround() (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

floatsin(softfloat) (CONST)

floatsin() (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

floatsinh(softfloat) (CONST)

floatsinh() (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

floatsqrt(softfloat) (CONST)

floatsqrt() (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

floattan(softfloat) (CONST)

floattan() (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

floattanh(softfloat) (CONST)

floattanh() (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.

There are no comments yet

Leave a Comment



?
? ?
?

 
Powered by TalkBack