The math functions shown below are part of the SQLite amalgamation source file but are only active if the amalgamation is compiled using the -DSQLITE_ENABLE_MATH_FUNCTIONS compile-time option.
The arguments to math functions can be integers, floating-point numbers, or strings or blobs that look like integers or real numbers. If any argument is NULL or is a string or blob that is not readily converted into a number, then the function will return NULL. These functions also return NULL for domain errors, such as trying to take the square root of a negative number, or compute the arccosine of a value greater than 1.0 or less than -1.0.
The values returned by these functions are often approximations. For example, the pi() function returns 3.141592653589793115997963468544185161590576171875 which is about 1.22465e-16 too small, but it is the closest approximation available for IEEE754 doubles.
Return the arccosine of X. The result is in radians.
Return the hyperbolic arccosine of X.
Return the arcsine of X. The result is in radians.
Return the hyperbolic arcsine of X.
Return the arctangent of X. The result is in radians.
Return the arctangent of Y/X. The result is in radians. The result is placed into correct quadrant depending on the signs of X and Y.
Return the hyperbolic arctangent of X.
Return the first representable integer value greater than or equal to X. For positive values of X, this routine rounds away from zero. For negative values of X, this routine rounds toward zero.
Return the cosine of X. X is in radians.
Return the hyperbolic cosine of X.
Convert value X from radians into degrees.
Compute e (Euler's number, approximately 2.71828182845905) raised to the power X.
Return the first representable integer value less than or equal to X. For positive numbers, this function rounds toward zero. For negative numbers, this function rounds away from zero.
Return the natural logarithm of X.
Return the base-10 logarithm for X. Or, for the two-argument version, return the base-B logarithm of X.
Compatibility note: SQLite works like PostgreSQL in that the log() function computes a base-10 logarithm. Most other SQL database engines compute a natural logarithm for log(). In the two-argument version of log(B,X), the first argument is the base and the second argument is the operand. This is the same as in PostgreSQL and MySQL, but is reversed from SQL Server which uses the second argument as the base and the first argument as the operand.
Return the logarithm base-2 for the number X.
Return the remainder after dividing X by Y. This is similar to the '%' operator, except that it works for non-integer arguments.
Return an approximation for π.
Compute X raised to the power Y.
Convert X from degrees into radians.
Return the sine of X. X is in radians.
Return the hyperbolic sine of X.
Return the square root of X. NULL is returned if X is negative.
Return the tangent of X. X is in radians.
Return the hyperbolic tangent of X.
Return the representable integer in between X and 0 (inclusive) that is furthest away from zero. Or, in other words, return the integer part of X, rounding toward zero. The trunc() function is similar to ceiling(X) and floor(X) except that it always rounds toward zero whereas ceiling(X) and floor(X) round up and down, respectively.
This page last modified on 2022-04-18 02:55:50 UTC
*** DRAFT ***