Re: [HACKERS] Datatype MONEY

From: wieck(at)debis(dot)com (Jan Wieck)
To: zakkr(at)zf(dot)jcu(dot)cz (Karel Zak - Zakkr)
Cc: wieck(at)debis(dot)com, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Datatype MONEY
Date: 1999-12-13 14:52:25
Message-ID: m11xWpt-0003kGC@orion.SAPserv.Hamburg.dsh.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Well, on a datetype is depend only small part in to_char(), I try
> write to_char(numeric, text) version. But I must first explore
> NUMERIC datetupe... (documentation is quiet for this).

NUMERIC's output function returns a null terminated string
representation as usual. Possibly a dash (negative sign), one
or more digits, optionally followed by a decimal point and
one or more digits. And you could get it with an adjusted
number of digits after the decimal point by doing

text *numeric_to_char(Numeric num, format text)
{
char *numstr;
int32 scale;

... /* calculate the wanted number of digits */
... /* after DP in scale depending on format */

numstr = numeric_out(numeric_round(num, scale));
}

There will be "scale" number of digits after the DP, which is
missing if scale is zero. The value will be correct rouded
and/or zero padded at the end.

Wouldn't that be enough for you?

Well, you must work on the string only and cannot read it
into a float internally, but with the above preprocessing, it
should be fairly simple.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#========================================= wieck(at)debis(dot)com (Jan Wieck) #

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jan Wieck 1999-12-13 15:13:29 Re: [HACKERS] Datatype MONEY
Previous Message Zeugswetter Andreas SB 1999-12-13 14:49:51 AW: [HACKERS] generic LONG VARLENA