Re: [HACKERS] Datatype MONEY
От | wieck@debis.com (Jan Wieck) |
---|---|
Тема | Re: [HACKERS] Datatype MONEY |
Дата | |
Msg-id | m11xWpt-0003kGC@orion.SAPserv.Hamburg.dsh.de обсуждение исходный текст |
Ответ на | Re: [HACKERS] Datatype MONEY (Karel Zak - Zakkr <zakkr@zf.jcu.cz>) |
Ответы |
Re: [HACKERS] Datatype MONEY
|
Список | 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@debis.com (Jan Wieck) #
В списке pgsql-hackers по дате отправления: