Which is more suitable for prices calculations in Firebird: decimal or numeric?
The implementation for both NUMERIC
and DECIMAL
are almost identical in Firebird. The Interbase 6.0 Data Definition Guide says there is a subtle difference (for NUMERIC
precision is exactly as declared, for DECIMAL
the precision is at least equal to declared). According to The Firebird Book by Helen Borrie there is only a difference for numbers with a precision of less than 5 as a NUMERIC
of precision 1-4 is mapped to a SMALLINT
while a DECIMAL
of precision 1-9 is mapped to INTEGER
. This book also remarks that both NUMERIC
and DECIMAL
conform to the behavior of the SQL-92 type DECIMAL
.
So with that said, I'd advise to go for DECIMAL
, as its behaviour conforms to that defined in the SQL standards and therefor holds less surprise for people unfamiliar with Firebird, but who do understand the standard behaviour.
They're both equally suitable for price calculations. But there will always be certain kinds of calculations that require rounding, no matter which of these you use.
Decimal is the more flexible of the two.