Subject Re: [firebird-support] Decimal field precision question
Author Alexandre Benson Smith
Jeff Dunlap wrote:
> Dear FB Users:
> I have installed the latest version of FB2 and created a Decimal field (3,3). Here is the applicable DDL:
> I am trying to store values such as 2.575 or 95.555 percent for instance. What is confusing me is that these fields are allowing me to store much larger values such as:
> 1300000.532
> The Interbase 6 PDF states that DECIMAL(precision, scale), where precision = 1 to 18 digits of precision to store and scale = 0 to 18 is the number of decimal places that can be stored.
> I am confused because in my case, DECIMAL(3,3) stores a max of 3 decimal places but why does it allow me to store precision in the millionth place?
> Please advise,
> Jeff

I think the type you wish is Decimal(6,3) theorically 999.999. Decimal
(3,3) would be something like 0.999.

*But* FB does not impose the limit by itself, you need to use a CHECK
CONSTRAINT to limit the maximum filed value, the type used by FB to
store decimal(6,3) is a 32 bit integer and the maximum allowed values
will be 2^31/1000

see you !

Alexandre Benson Smith
THOR Software e Comercial Ltda
Santo Andre - Sao Paulo - Brazil