Blaze
Blaze

Reputation: 2329

type float4 in postgres truncates values

I am trying to insert values into a field in postgres. The data type in that field is float4. When I try to insert values into it, I get the value truncated as shown below

value: 18754999.99, pgAdmin truncates to 18755000

Please how can I prevent the truncation using float4 datatype

Upvotes: 2

Views: 868

Answers (1)

Laurenz Albe
Laurenz Albe

Reputation: 246898

float4 a.k.a. real is stored in 4 bytes and has very limited precision. If you want more precision, use float8 a.k.a. double precision. If you want no rounding errors at all, use numeric.

Upvotes: 6

Related Questions