Subject Re: [firebird-support] Datatype Numeric rounding issues
Author Fidel Viegas
On Mon, Mar 3, 2008 at 8:41 AM, Martins Lazdans <marrtins@...> wrote:

> Hello!
>
> I`m kinda confused about how Firebird rounds numeric datatypes. Here`s
> an example:
>
> SELECT CAST(3.6648 AS NUMERIC(9, 2)) FROM rdb$database
> Results in: 3.66
>
> SELECT CAST(3.6648 AS NUMERIC(9, 3)) FROM rdb$database
> Results in: 3.665
>
> My question: should`nt it result in 3.67 in first example? Tested on
> `Firebird_2_1_0_17735-0_Win32` and `Firebird_2_0 `

No, it would only be rounded to 3.67 if the number following the
second decimal place was greater than 4. For instance, 3.6658 would
give you 3.67. In the second case you get 3.665 because the 4 gets
rounded to 5, as it is followed by a number greater than 4.

But just like Martin suggested, have a look at the link he provided.
That explains it all.

All the best,

Fidel.