SQLSTATE 22003 ERROR Class 22: Data Exception

numeric_value_out_of_range value out of range: underflow — 22003

PostgreSQL error "value out of range: underflow" (SQLSTATE 22003): what it means, common causes, and how to fix it.

PG 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed May 2025 Grounded in source

Diagnostic Queries

Symptoms

A floating-point computation produced a magnitude too small to represent (underflow). PostgreSQL raises SQLSTATE 22003 (numeric_value_out_of_range).

  • A result is smaller than the smallest representable nonzero value.
  • Common with division or exponential operations.
  • Affects real/double precision computations.

What the server log shows

ERROR:  value out of range: underflow

Why PostgreSQL raises this — what the manual says

Section 8.1.3 Floating-Point Types:

“Numbers too close to zero that are not representable as distinct from zero will cause an underflow error.”

IEEE 754 types have a smallest representable nonzero magnitude. A computation producing a value below that threshold underflows, and PostgreSQL reports 22003.

Common causes

  • Repeated division producing extremely small numbers.
  • Exponential/logarithmic math driving values toward zero.
  • Scaling values below the type’s precision floor.

How to fix it

  1. Use numeric for arbitrary precision where tiny magnitudes matter.
  2. Rescale the computation to keep values in range.
  3. Clamp or round near-zero results in the application.

Related & next steps

Reference: PostgreSQL 18 Section 8.1 “Numeric Types”.

Was this helpful?