Re: [SQL] Decimal precsion? - Mailing list pgsql-sql

From Bruce Momjian
Subject Re: [SQL] Decimal precsion?
Date
Msg-id 199910301555.LAA04741@candle.pha.pa.us
Whole thread Raw
In response to Re: [SQL] Decimal precsion?  (wieck@debis.com (Jan Wieck))
Responses Re: [SQL] Decimal precsion?  (wieck@debis.com (Jan Wieck))
List pgsql-sql
> >
> > >
> > > Yeah I finnally figured that out, wish the docs would cover things like
> > > that.
> > >
> > > I went through two books (which said its just liek COBOL! and then
> > > ignored me) and finnally the mysql pages had a good right up.
> > >
> > > I still thing the 0.0 thing is an error.
> > >
> >
> > Yes, and why doesn't this generate an error:
> >
> >    test=> insert into example values(0.12345);
> >    INSERT 19488 1
> >    test=> insert into example values(0.1234567);
> >    INSERT 19489 1
> >    test=> select * from example;
> >     other
> >    ------
> >    0.1235
> >    0.1235
> >    (2 rows)
> >
> > Jan, can you comment on this.  I found the code in numeric.c, but can't
> > figure out what the proper test should be.
> 
>     Haven't  seen  the  original message, but it looks to me that
>     the column is declared as decimal with  4  digits  after  the
>     decimal  point. Therefore, all values get rounded at the time
>     of INSERT/UPDATE. The above looks numerically right to me.
> 
>     Isn't  that  behaviour  correct?  Does  the  standard  define
>     something else?

OK, I wasn't sure on whether rounding was correct.

However, the original message had DECIMAL(4,4) and he could insert 0.1,
but not 0.0.

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


pgsql-sql by date:

Previous
From: wieck@debis.com (Jan Wieck)
Date:
Subject: Re: [SQL] Decimal precsion?
Next
From: wieck@debis.com (Jan Wieck)
Date:
Subject: Re: [SQL] Decimal precsion?