Subject Re: [ib-support] Re: decimal / numeric
Author Claudio Valderrama C.
""csswa"" <csswa@...> wrote in message
news:a8vagr+muv6@......
> The only difference I can see between numeric and decimal types is=20
> that decimal has a sliding precision: decimal(4,2) will accept a=20
> value of 12345678 whereas numeric(4,2) will reject it. So even=20
> though the decimal is defined nominally as four digits (smallint, two=20
> bytes) it actually defines the field as four bytes. Just seems like=20
> slight of hand, but there must be good reason for the distinction=20
> between the two types.

Decimal is dependent on the implementation. In IB/FB, for both decimal(p,s)
and numeric (p,s) you have
p < 5 => smallint is used as storage, hence limit is 32K
5 <= p < 10 => integer is used, hence limit is 2^31
11 <= p => double precision in dialect 1, int64 (2^63) in dialect 3.

In a true numeric(p,s) implementation, if you say p=3 for example, the
engine should reject anything where the whole part of the number has more
digits than 3-s, so for example
numeric(3,1) => p-s = 2
should accept 1.2 & 12.3 but not 123.4


> What would be a real-world example of where you would use decimal=20
> rather than numeric?

You have used it all the time with IB/FB.
:-)

As a side effect, I imagine the day we'll change it, most people won't turn
their declaration into DECIMAL type for legacy applications, hence we will
be flooded with whining only comparable to the "ambiguous field" check.

C.
--
Claudio Valderrama C. - http://www.cvalde.com - http://www.firebirdSql.org
Independent developer
Owner of the Interbase® WebRing