[GENERAL] Numeric numbers - Mailing list pgsql-general

From Олег Самойлов
Subject [GENERAL] Numeric numbers
Date
Msg-id 1504361765.16542.8.camel@mipt.ru
Whole thread Raw
Responses Re: [GENERAL] Numeric numbers
Re: [GENERAL] Numeric numbers
List pgsql-general
Hi all. I have silly question. Look at "numeric" type. According to
docs it must be "up to 131072 digits before the decimal point; up to
16383 digits after the decimal point". Well, lets see.

=> select 1::numeric/3;
        ?column?        
------------------------
 0.33333333333333333333

Well, I expect 16383 digits after ".". But nope.
=> select (1::numeric/3-0.33333333333333333333)*1e20;
        ?column?        
------------------------
 0.00000000000000000000
=> select (1::numeric/3-0.33333333333333333332)*1e20;
        ?column?        
------------------------
 1.00000000000000000000

There is only 20 "3" after ".". Well, may be this is not a problem, but
why are they infinite number of "0" after the point? I can write even

=> select (1::numeric/3-0.33333333333333333333)*1e100000;
        ?column?        
------------------------
 0.00000000000000000000

Result the same. According to the docs: "Numeric values are physically
stored without any extra leading or trailing zeroes."


pgsql-general by date:

Previous
From: Ken Tanzer
Date:
Subject: Re: [GENERAL] Fields re-ordered on JOIN with * and USING
Next
From: Francisco Olarte
Date:
Subject: Re: [GENERAL] Numeric numbers