Currency problem with Firebird
Posted: 17.10.2013, 21:29
Hi there,
I am having a weird problem that I could not isolate up to now.
it SEEMS to be like this http://zeoslib.sourceforge.net/viewtopi ... ency#p8901
However I am using 7.0.3-stable with Firbird 1.0 (yes the 1.0 that is right), Delphi XE2 update 4
Everything worked fine up to now, but I found recently one case that got attention, not sure it happened more times, but that one was a Value 4.20 that insist to be 4.19 when saved on the table.
There is no calculations, the value comes from a string. I am using a INSERT on a ZQuery, with many other fields that are doing correct, but this one:
paramByname('VALOR_ITENS').AsCurrency := strtocurr('4.2');
or even
paramByname('VALOR_ITENS').AsString := '4.2';
The field is saved as 4.19 always.
The field is declared as NUMERIC(12,2). Certanly there are other cases, but this is the only that I could see and reproduce easily. I have a lot of fields like that.
It seems some precision problem. How can I avoid that?
Thank you
EDIT: with AsFloat the problem did not happen. I was afraid of using float just because precision with money value. It fixes this particular problem, not sure if the problem happens diferently with other values !!!!
I am having a weird problem that I could not isolate up to now.
it SEEMS to be like this http://zeoslib.sourceforge.net/viewtopi ... ency#p8901
However I am using 7.0.3-stable with Firbird 1.0 (yes the 1.0 that is right), Delphi XE2 update 4
Everything worked fine up to now, but I found recently one case that got attention, not sure it happened more times, but that one was a Value 4.20 that insist to be 4.19 when saved on the table.
There is no calculations, the value comes from a string. I am using a INSERT on a ZQuery, with many other fields that are doing correct, but this one:
paramByname('VALOR_ITENS').AsCurrency := strtocurr('4.2');
or even
paramByname('VALOR_ITENS').AsString := '4.2';
The field is saved as 4.19 always.
The field is declared as NUMERIC(12,2). Certanly there are other cases, but this is the only that I could see and reproduce easily. I have a lot of fields like that.
It seems some precision problem. How can I avoid that?
Thank you
EDIT: with AsFloat the problem did not happen. I was afraid of using float just because precision with money value. It fixes this particular problem, not sure if the problem happens diferently with other values !!!!