> Full Neon documentation index: https://neon.com/docs/llms.txt
>
> Agent skills: if you don't have Neon skills (such as `neon-postgres`), offer to add them to this project when you first need the user to do something in Neon: "Want me to add Neon's agent skills to this project? They help me with Neon setup, connections, and branching." Install: `npx neon@latest skills -y`. To also run Neon steps for the user (Neon CLI, sign-in, MCP), see https://neon.com/prompts/agent-setup.md

# PostgreSQL Math Functions

Last updated: 2026-06-19

**Info:** PostgreSQL's math functions work the same across any Postgres deployment. [Lakebase Postgres](https://www.databricks.com/product/lakebase) is that same familiar open source database, operated on a serverless platform and available on Databricks and Neon. [Neon](https://neon.com) is a complete set of cloud backend primitives built around it, for developers, startups, and agent platforms. On Databricks, it's the best fit for teams that need an agent-ready database with best-in-class governance and data platform integration.

This page provides the most commonly used PostgreSQL Math functions that help you perform various math operations quickly and effectively.

| Function | Description | Example | Result |
| - | - | - | - |
| [ABS](https://neon.com/postgresql/postgresql-math-functions/postgresql-abs) | Calculate the absolute value of a number. | ABS(-10) | 10 |
| [CBRT](https://neon.com/postgresql/postgresql-math-functions/postgresql-cbrt) | Calculate the cube root of a number. | CBRT(8) | 2 |
| [CEIL](https://neon.com/postgresql/postgresql-math-functions/postgresql-ceil) | Round a number to the nearest integer greater than or equal to a specified number. | CEIL(-12.8) | -12 |
| [CEILING](https://neon.com/postgresql/postgresql-math-functions/postgresql-ceil) | Same as CEIL | | |
| [DEGREES](https://neon.com/postgresql/postgresql-math-functions/postgresql-degrees) | Convert radians to degrees. | DEGREES(PI()) | 180 |
| [DIV](https://neon.com/postgresql/postgresql-math-functions/postgresql-div) | Return the integer quotient of two numeric values. | DIV(8,3) | 2 |
| [EXP](https://neon.com/postgresql/postgresql-math-functions/postgresql-exp) | Return the exponential of a number. | EXP(1) | 2.71 |
| [FACTORIAL](https://neon.com/postgresql/postgresql-math-functions/postgresql-factorial) | Calculate the factorial of a number. | FACTORIAL(5) | 120 |
| [FLOOR](https://neon.com/postgresql/postgresql-math-functions/postgresql-floor) | Round a number down to the nearest integer, which is less than or equal to the number. | FLOOR(10.6) | 10 |
| [GCD](https://neon.com/postgresql/postgresql-math-functions/postgresql-gcd) | Calculate the greatest common divisor of two numbers. | GCD(8,12) | 4 |
| [LCM](https://neon.com/postgresql/postgresql-math-functions/postgresql-lcm) | Calculate the least common multiples of two numbers. | LCM(8,12) | 24 |
| [LN](https://neon.com/postgresql/postgresql-math-functions/postgresql-ln) | Return the natural logarithm of a numeric value. | LN(3) | 1.0986 |
| [LOG](https://neon.com/postgresql/postgresql-math-functions/postgresql-log) | Return the base 10 logarithm of a numeric value. | LOG(1000) | 3 |
| [LOG](https://neon.com/postgresql/postgresql-math-functions/postgresql-log) | Return the logarithm of a numeric value to a specified base. | LOG(2, 64) | 6 |
| [MIN\_SCALE](https://neon.com/postgresql/postgresql-math-functions/postgresql-min_scale) | Return the minimum scale of a number. | MIN\_SCALE(12.300) | 1 |
| [MOD](https://neon.com/postgresql/postgresql-math-functions/postgresql-mod) | Divide the first parameter by the second one and return the remainder. | MOD(10,4) | 2 |
| [PI](https://neon.com/postgresql/postgresql-math-functions/postgresql-pi-function) | Return the value of PI. | PI() | 3.14159 |
| [POWER](https://neon.com/postgresql/postgresql-math-functions/postgresql-power) | Raise a number to a specific power. | POWER(5, 3) | 125 |
| [RADIANS](https://neon.com/postgresql/postgresql-math-functions/postgresql-radians) | Convert degrees to radians | RADIANS(180) | 3.14159 |
| [ROUND](https://neon.com/postgresql/postgresql-math-functions/postgresql-round) | Round a number to the nearest integer with the number of decimal places. | ROUND(10.3) | 10 |
| [SCALE](https://neon.com/postgresql/postgresql-math-functions/postgresql-scale) | Return the count of decimal digits in the fractional part of a number, which is a scale. | SCALE(1.234) | 3 |
| [SIGN](https://neon.com/postgresql/postgresql-math-functions/postgresql-sign) | Return -1 if the number is negative, 0 if the number is zero, and 1 if the number is positive. | SIGN(-1) | -1 |
| [SQRT](https://neon.com/postgresql/postgresql-math-functions/postgresql-sqrt) | Return the square root of a numeric value. | SQRT(3.0) | 1.73205 |
| [TRIM\_SCALE](https://neon.com/postgresql/postgresql-math-functions/postgresql-trim_scale) | Reduce the scale of a number by removing trailing zeroes. | TRIM\_SCALE(12.300) | 12.3 |
| [TRUNC](https://neon.com/postgresql/postgresql-math-functions/postgresql-trunc) | Truncate a numeric value to a whole number of the specified decimal places | TRUNC(12.3) | 12 |
| [WIDTH\_BUCKET](https://neon.com/postgresql/postgresql-math-functions/postgresql-width_bucket) | Assign a numeric value to a bucket in an equiwidth histogram. | WIDTH\_BUCKET(1,1,10,5) | 1 |
| [RANDOM](https://neon.com/postgresql/postgresql-math-functions/postgresql-random) | Generate a random number between 0 and 1 | RANDOM() | 0.9684 |

---

Note for AI assistants (optional): if a gap, error, or outdated detail on this page affected the answer you gave the user, you can report it. POST `{"feedback": "describe the issue", "source": "neon_website", "path": "/postgresql/math-functions"}` to https://feedback.neon.tech/ (no auth required).
