Materialize Logo

Floating-Point Data Types

real info

Detail Info
Size 4 bytes
Aliases float4
Catalog name pg_catalog.float4
OID 700
Range Approx. 1E-37 to 1E+37 with 6 decimal digits of precision

double precision info

Detail Info
Size 8 bytes
Aliases float,float8, double
Catalog name pg_catalog.float8
OID 701
Range Approx. 1E-307 to 1E+307 with 15 decimal digits of precision

Syntax

int . frac

Details

Literals

Materialize assumes untyped numeric literals containing decimal points are numeric; to use float, you must explicitly cast them as we’ve done below.

Special values

Floating-point numbers have three special values, as specified in IEEE 754:

Value Aliases Represents
NaN Not a number
Infinity Inf, +Infinity, +Inf Positive infinity
-Infinity -Inf Negative infinity

To input these special values, write them as a string and cast that string to the desired floating-point type. For example:

SELECT 'NaN'::real AS nan
 nan
-----
 NaN

The strings are recognized case insensitively.

Valid casts

In addition to the casts listed below, real and double precision values can be cast to and from one another. The cast from real to double precision is implicit and the cast from double precision to real is by assignment.

From real

You can cast real or double precision to:

To real

You can cast to real or double precision from the following types:

Examples

SELECT 1.23::real AS real_v;
 real_v
---------
    1.23
Did this info help?
Yes No