Re: select to_number('1,000', '999,999'); - Mailing list pgsql-bugs

From Tom Lane
Subject Re: select to_number('1,000', '999,999');
Date
Msg-id 15875.1101139736@sss.pgh.pa.us
Whole thread Raw
In response to Re: select to_number('1,000', '999,999');  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Responses Re: select to_number('1,000', '999,999');
List pgsql-bugs
Stephan Szabo <sszabo@megazone.bigpanda.com> writes:
> No, but I think you're supposed to use FM in such cases.
>
> select to_number(1000, 'FM999,999');

Good point --- I had forgot about FM.  In that case there *is* a bug
here, but I'm not sure if it's with to_char or to_number:

regression=# select to_number(to_char(1000, 'FM999,999'),'FM999,999');
 to_number
-----------
      1000
(1 row)

regression=# select to_number(to_char(1000, '999,999'),'999,999');
 to_number
-----------
       100
(1 row)

Whatever your opinion is about the behavior of the non-FM format, surely
to_char and to_number should be inverses.

            regards, tom lane

pgsql-bugs by date:

Previous
From: David Schweikert
Date:
Subject: Re: select to_number('1,000', '999,999');
Next
From: Nicola Pero
Date:
Subject: Data corruption/loss when altering tables (fwd)