Re: Request to clarify on sql_numeric datatype

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Raghavendra Reddy <raghavendrar(at)aztec(dot)soft(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Request to clarify on sql_numeric datatype
Date: 2005-09-16 14:11:54
Message-ID: 248.1126879914@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Raghavendra Reddy <raghavendrar(at)aztec(dot)soft(dot)net> writes:
> While inserting numeric data type into a table can you please let me
> know how you are storing the value in the database.

>From src/include/utils/numeric.h:

/*
* The Numeric data type stored in the database
*
* NOTE: by convention, values in the packed form have been stripped of
* all leading and trailing zero digits (where a "digit" is of base NBASE).
* In particular, if the value is zero, there will be no digits at all!
* The weight is arbitrary in that case, but we normally set it to zero.
*/
typedef struct NumericData
{
int32 varlen; /* Variable size (std varlena header) */
int16 n_weight; /* Weight of 1st digit */
uint16 n_sign_dscale; /* Sign + display scale */
char n_data[1]; /* Digits (really array of NumericDigit) */
} NumericData;

See also the comments at the top of src/backend/utils/adt/numeric.c.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-09-16 14:15:01 Re: New dot releases
Previous Message Neil Conway 2005-09-16 13:57:29 Re: Beta2 Wrap Up ...