Re: float formating with xx.00

Поиск
Список
Период
Сортировка
От Dann Corbit
Тема Re: float formating with xx.00
Дата
Msg-id D90A5A6C612A39408103E6ECDD77B8294CDE7F@voyager.corporate.connx.com
обсуждение исходный текст
Ответ на float formating with xx.00  (Mark <map@inter-resa.com>)
Ответы Re: float formating with xx.00  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
> -----Original Message-----
> From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
> Sent: Thursday, July 03, 2003 6:33 PM
> To: Dann Corbit
> Cc: map@inter-resa.com; pgsql-general@postgresql.org
> Subject: Re: [GENERAL] float formating with xx.00
>
>
> "Dann Corbit" <DCorbit@connx.com> writes:
> >> Thanks... but will a numeric data type for money display the
> >> same output as
> >> the input? Ex.: I enter, 19.1  will it show 19.10  or 19.1 ?
>
> > If you are saying that you want the program to 'remember'
> exactly what
> > you typed in and use that, then you are stuck with strings.
>
> No, actually a column declared "numeric" (without any specific
> precision) will do that for him.  This is a better choice
> than using a string IMHO.
>
> regression=# select '123.45'::numeric;
>  numeric
> ---------
>   123.45
> (1 row)
>
> regression=# select '123.4'::numeric;
>  numeric
> ---------
>    123.4
> (1 row)
>
> regression=# select '123.0'::numeric;
>  numeric
> ---------
>    123.0
> (1 row)
>
> Not SQL-spec AFAIR, but Postgres will take it.

Can't say I am really positive what he was after.  But I am not sure
that numeric without precision or scale qualfication will achieve his
goals either.

connxdatasync=# insert into test values (.99999999999999999999999999999)
connxdatasync-# ;
INSERT 29198 1
connxdatasync=# insert into test
values(99999999999999.99999999999999999999999999999999999999999999999999
999999999999999)
connxdatasync-# ;
INSERT 29199 1
connxdatasync=# create table test2 (foo numeric);
CREATE
connxdatasync=# insert into test2 values
(0.00000000000000000000000000000000000000);
INSERT 29210 1
connxdatasync=# insert into test2 values
(10.000000000000000000000000000000000000001);
INSERT 29211 1
connxdatasync=# insert into test2 values
(10.00000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000001);
INSERT 29212 1
connxdatasync=# insert into test2 values
(0.000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000001);
INSERT 29213 1
connxdatasync=# insert into test values (1.0/7.0);
INSERT 29214 1
connxdatasync=# insert into test2 values (1.0/7.0);
INSERT 29215 1
connxdatasync=# select foo::numeric from test;
     ?column?
-------------------
                 1
              2.25
              1.27
               1.1
                 1
   100000000000000
 0.142857142857143
(7 rows)

connxdatasync=# select foo from test2;
    foo
-----------
  0.000000
 10.000000
 10.000000
  0.000000
  0.142857
(5 rows)

Don't know if this is the sort of result hoped for or not.  Probably
not.

Now, this is 7.1.3.  Don't know if 7.4 (or other flavors) behave
differently.

В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: float formating with xx.00
Следующее
От: Mark
Дата:
Сообщение: Re: float formating with xx.00