Re: float formating with xx.00 - Mailing list pgsql-general

From Dann Corbit
Subject Re: float formating with xx.00
Date
Msg-id D90A5A6C612A39408103E6ECDD77B8294CDE7F@voyager.corporate.connx.com
Whole thread Raw
In response to float formating with xx.00  (Mark <map@inter-resa.com>)
Responses Re: float formating with xx.00
List 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 by date:

Previous
From: Tom Lane
Date:
Subject: Re: float formating with xx.00
Next
From: Mark
Date:
Subject: Re: float formating with xx.00