Fwd: error in the example given for numeric data types

From: Priyank Rajvansh <rajvansh(dot)priyank(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Fwd: error in the example given for numeric data types
Date: 2023-07-15 06:38:26
Message-ID: CAMyMXf2g1WaiQtoy7XtObTfCC+2WH1ZteGzbdhyx+4PwSiPGcA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Respected postgresql team,forwarded email.

Thank You

Kindly have a look at the
---------- Forwarded message ---------
From: PG Doc comments form <noreply(at)postgresql(dot)org>
Date: Sat, Jan 28, 2023 at 11:22 AM
Subject: error in the example given for numeric data types
To: <pgsql-docs(at)lists(dot)postgresql(dot)org>
Cc: <rajvansh(dot)priyank(at)gmail(dot)com>

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/15/datatype-numeric.html
Description:

article 8.1.2 states the following:

''We use the following terms below: The precision of a numeric is the total
count of significant digits in the whole number, that is, the number of
digits to both sides of the decimal point. The scale of a numeric is the
count of decimal digits in the fractional part, to the right of the decimal
point. So the number 23.5141 has a precision of 6 and a scale of 4. Integers
can be considered to have a scale of zero.''

however it also states the following towards the end:

'' For example, a column declared as

NUMERIC(3, 5)
will round values to 5 decimal places and can store values between -0.00999
and 0.00999, inclusive.''

Now from whatever i could decipher the syntax of the numeric data type is
NUMERIC(precision,scale) and if we write NUMERIC (3,5) it would mean that we
are trying to store a number which has 3 digits in total and 5 of them are
to the right of the decimal point, which doesn't make sense !
besides i tried running this in postgresql and the result was as follows:

practice=# create table t1(height numeric(3,5));
ERROR: NUMERIC scale 5 must be between 0 and precision 3
LINE 1: create table t1(height numeric(3,5));
Please look into the matter and kindly revert back to me whatever you find
out about this so that i can correct myself incase i misunderstood what the
document says...

Responses

Browse pgsql-general by date

  From Date Subject
Next Message jian he 2023-07-15 07:16:45 Re: error in the example given for numeric data types
Previous Message Amit Kapila 2023-07-14 10:33:15 Re: Support logical replication of DDLs