Subject RE: [firebird-support] Datatype Numeric rounding issues
Author Svein Erling Tysvær
Why would you want to round to 3.67? The bankers rounding that Martijn talks about, rounds to the even number in case of something exactly in between two numbers, e.g. if your number had been 3.665, bankers rounding would round to 3.66 since 6 is an even number whereas 7 is odd. 3.6648 rounds down if rounded to two decimals in all cases of rounding that I've ever heard of (well, except that I might have heard of CEILING that always rounds UP) since it is closer to 3.66 than 3.67.

Set

-----Original Message-----
From: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com] On Behalf Of Martins Lazdans
Sent: 3. mars 2008 09:42
To: firebird-support@yahoogroups.com
Subject: [firebird-support] Datatype Numeric rounding issues

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 `

Tried dialect 1 and 3 too

Thanks for your help!