Sql - postgres - Arbitrary accuracy ::

Asked

Viewed 604 times

2

How arbitrary precision works when defining the column as numeric?

  • 2

    http://answall.com/questions/92588/valida%C3%A7%C3%A3o-numeric12-2-postgres/92655#92655

1 answer

2


From the Postgres manual we can see that the Numeric has:

131072 digits before decimal point
16383 digits after decimal point

This is the default value, however it is possible to set this pattern with :

numeric(num1, num2)

In which num1 is accuracy, or how many digits I want to have my Numeric.
And num2 is how many decimals he must have.

It should be noted that num2 uses the definition of num1 that is, it is not a sum of digits, is the use of it, example:

EX1 : numeric(12,2) // estou dizendo que terei 12 digitos, sendo 2 decimais.
EX2 : numeric(8,6)  // estou dizendo que terei 8 digitos, sendo 6 decimais.

In this situation of mine EX1 sluice 9.999.999.999,99.
While EX2 can’t get past 99,999999; because I set a total of 8 digits to 6 decimal places.

Analogy

subtracting num2 of num1 we will have the amount of decimals supported in our column.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.