Re: numeric rounding

Поиск
Список
Период
Сортировка
От James Moe
Тема Re: numeric rounding
Дата
Msg-id auto-000000650502@sohnen-moe.com
обсуждение исходный текст
Ответ на numeric rounding  (Gezeala 'Eyah' "Bacuño" II <gezeala25@yahoo.com>)
Список pgsql-general
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, 29 Sep 2003 00:47:05 -0700 (PDT), Gezeala 'Eyah' \"Bacu±o\" II wrote:

>i have a plpgsql function where in i compute numeric values for my php scripts..
>my problem is my function just won't round some numbers properly.
>
  What do you mean by "properly?" How, exactly, do you want the numbers rounded? What
about negative numbers?
  There is a round() function that offers various options. I do not know how it handles
negative numbers, though.
  For money numbers I found this to be a reasonable method:

  sign = (0.0 <= N) ? 1 : -1;
  tmp  = abs(N);
  tmp  = round((tmp + 0.005), 2);
  N    = tmp * sign;


- --
jimoe at sohnen-moe dot com
pgp/gpg public key: http://www.keyserver.net/en/
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 5.0 OS/2 for non-commercial use
Comment: PGP 5.0 for OS/2
Charset: cp850

wj8DBQE/eHV9sxxMki0foKoRAnitAJ4yd1LG4eBlNpsQL3tFLqera9JRQACg3rKX
LnDwRQkyga6uxBzeEjEX+qE=
=LIzc
-----END PGP SIGNATURE-----





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

Предыдущее
От: Josh Berkus
Дата:
Сообщение: Re: [SQL] Conditional row grained + FK dependency oriented lazy replication
Следующее
От: Robert Treat
Дата:
Сообщение: Re: Postgres vs. Progress performance