w3resource logo


>SQLite abs function

SQLite abs() function

Secondary Nav

Description

SQLite abs() function returns the absolute value of a number.

  • The abs(X) function returns the absolute value of the numeric argument X. Abs(X) returns NULL if X is NULL.
  • abs(X) return 0.0 if X is a string or blob that cannot be converted to a numeric value.
  • If X is the integer -9223372036854775808 then abs(X) throws an integer overflow error since there is no equivalent positive 64-bit two complement value.

Syntax

abs(X)

Argument

Name Description
X A number whose absolute value is to be retrieved.

Example: SQLite abs() function

The following SQLite statement will return the absolute value of a positive number specified in the argument.

sqlite> SELECT abs(5);

Here is the result.

abs(5)
----------
5

Example: SQLite abs() function using negative value

The following SQLite statement will return the absolute value of a negative number defined in the argument.

sqlite> SELECT abs(-5);

Here is the result.

abs(-5)
----------
5


Join our Question Answer community to learn and share your programming knowledge.

Help the community:

Python: Fizzbuzz

C++: Decimal to binary conversion

JavaScript: Need Help in JavaScript

Python: Help me with this program