Subject | Re: Firebird & double precision |
---|---|
Author | csswa |
Post date | 2002-04-18T13:23:01Z |
You are using a dialect 1 database, right? So the computed field is
returning a double precision value.
To avoid this in dialect 1, you can't define a numeric column bigger
than numeric(9,x). Once you are 10 and over it moves from integer
storage to double precision, hence no control over scale.
Dialect 3 defines numeric(10,x) and higher as INT64 so the results
returned will have the proper scale. I may need to check the docs on
this but I think that's all correct.
HTH,
Regards,
Andrew Ferguson
returning a double precision value.
To avoid this in dialect 1, you can't define a numeric column bigger
than numeric(9,x). Once you are 10 and over it moves from integer
storage to double precision, hence no control over scale.
Dialect 3 defines numeric(10,x) and higher as INT64 so the results
returned will have the proper scale. I may need to check the docs on
this but I think that's all correct.
HTH,
Regards,
Andrew Ferguson
--- In ib-support@y..., José Manuel <machacon_vaquero@h...> wrote:
> Hi,
>
> How must i define a computed field for take only 2 decimal
places?
>
> by example when i define this table:
>
> CREATE TABLE IVA (IV_CONTA STRING NOT NULL,
> IV_CONTADOR INTEGER NOT NULL,
> IV_TOTALFAC NUMERIC(15,2) DEFAULT 0 NOT
NULL,
> IV_RET_CUOTA NUMERIC(15,2) DEFAULT 0 NOT
NULL,
> IV_TOTLIQ COMPUTED BY (IV_TOTALFAC -
IV_RET_CUOTA),
> CONSTRAINT IVA_PK PRIMARY KEY
> (IV_CONTA,IV_CONTADOR));
>
> The value for iv_totalfac & iv_ret_cuota come from a
procedure and i see
> this view:
>
> iv_totalfac iv_ret_cuota iv_totliq
> -------------- ------------- --------------------
--
> 100.20 82.01
18.1900000000115
> 10.15 10.15
0.00000000000041
>
> why i don't get the correct computed value (it should be
18.19 and 0)
>
> thank in advance.
>
>
> PD.- Excuse my English.
>
>
> -----
> José Manuel
> CACERES (Spain)