min_scale()

A function returning the minimum scale needed to represent a value

min_scale() is a system function which returns the minimum scale (number of fractional decimal digits) needed to represent the supplied value precisely.

min_scale() was added in PostgreSQL 13.

Usage

min_scale ( numeric ) → integer

Change history

Examples

Execution examples for min_scale():

postgres=# SELECT min_scale(1.2300);
 min_scale
-----------
         2
(1 row)

postgres=# SELECT min_scale(1.23);
 min_scale
-----------
         2
(1 row)

postgres=# SELECT min_scale(1.0);
 min_scale
-----------
         0
(1 row)

postgres=# SELECT min_scale(1);
 min_scale
-----------
         0
(1 row)

Categories

System function

See also

scale(), trim_scale()