From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | jeff sacksteder <jsacksteder(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Implementing rounding rule in plpgsql |
Date: | 2005-11-20 15:40:51 |
Message-ID: | 20051120154051.GA38669@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sun, Nov 20, 2005 at 02:24:20AM -0700, Michael Fuhr wrote:
> On Sun, Nov 20, 2005 at 02:01:02AM -0500, jeff sacksteder wrote:
> > Due to application requirements, I need to implement a rounding function
> > that is independant of the baked-in rounding functionality. I'd prefer to do
> > it in plpgsql for maximum portability.
> > To do this, I'll need to sequentially walk through the digits of an
> > arbritarily long floating-point number. I can't think of a good way to do
> > this.
>
> This wouldn't be a homework assignment, would it? Anyway, maybe
> this will give you some ideas:
It occurred to me after I posted this that there might be a numerical
method for walking through the digits. Successive multiplication by
10 has problems due to the inaccuracies of floating-point arithmetic,
although using a numeric type instead of double precision might solve
that problem. Maybe somebody more familiar with numerical methods
than I will suggest something.
--
Michael Fuhr
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2005-11-20 16:53:15 | Re: Create role question |
Previous Message | Leif Jensen | 2005-11-20 14:29:05 | Re: Mambo (CMS) & PostgreSQL |