Re: numeric precision when raising one numeric to another. - Mailing list pgsql-general

From Bruce Momjian
Subject Re: numeric precision when raising one numeric to another.
Date
Msg-id 200505310422.j4V4Mrd23842@candle.pha.pa.us
Whole thread Raw
In response to Re: numeric precision when raising one numeric to another.  (Alvaro Herrera <alvherre@surnet.cl>)
List pgsql-general
Alvaro Herrera wrote:
> On Mon, May 30, 2005 at 11:29:48PM -0400, Bruce Momjian wrote:
>
> >     test=> select 12345678901234567890 / 123;
> >           ?column?
> >     --------------------
> >      100371373180768845
> >     (1 row)
>
> Well, that's a bug, right?

I don't think so.  The fuller answer is
100371373180768844.63414634146341463414, and that rounded to the nearest
integer is 100371373180768845.  I think people expect % do to that,
except for integers.  You could argue that numerics with zero scale are
integers, but NUMERIC % NUMERIC doesn't behave like an integer operator
--- it rounds to the proper precision.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

pgsql-general by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: numeric precision when raising one numeric to another.
Next
From: Ian Harding
Date:
Subject: Re: Carriage return in text fields