Subject | Re: [ib-support] Cast and rounding |
---|---|
Author | Claudio Valderrama C. |
Post date | 2001-09-04T07:01:08Z |
""Marcin Bury"" <mbury@...> wrote in message
news:001501c13441$0ffde2a0$c905a8c0@mb...
Test with negative values to be sure it does what you want in that case,
because it always rounds towards the absolute value.
The FBUDF by default does round() to the next greater value and trunc() to
the previous smaller value (although it can be compiled with a #define to
work in a symmetric way with negative values, same as cast() works) but
currently it doesn't accept scale as a parameter, so it always trims all
decimal places.
C.
--
Claudio Valderrama C. - http://www.cvalde.com - http://www.firebirdSql.org
Independent developer
Owner of the Interbase® WebRing
news:001501c13441$0ffde2a0$c905a8c0@mb...
> Hi ListI
>
> I have to cast the product of multiplying two numeric(9,4) values to
> numeric(9,2). Is the rounding ability of cast function reliable enough or
> have to use some UDF.In my experience, cast() always rounds.
Test with negative values to be sure it does what you want in that case,
because it always rounds towards the absolute value.
The FBUDF by default does round() to the next greater value and trunc() to
the previous smaller value (although it can be compiled with a #define to
work in a symmetric way with negative values, same as cast() works) but
currently it doesn't accept scale as a parameter, so it always trims all
decimal places.
C.
--
Claudio Valderrama C. - http://www.cvalde.com - http://www.firebirdSql.org
Independent developer
Owner of the Interbase® WebRing