On Wednesday, 04 June, 2014 04:39 AM, Daniel Erles wrote:
> Hello. 
> I have this problem: 
>
> My database (Firebird) has a table with the following fields: 
> ... 
> rTitle DECIMAL(8,4) not null,
> rDiameter DECIMAL(10,6) not null, 
> ... 
>
> In my program I have a Form with a a TZTable object (ZEOS) called
> zData, bound to that table. 
> In a routine I have the following code: 
>
> zData.Insert;
> ...
> zData.FieldByName('rTitle').AsFloat := 0.12; 
> zData.FieldByName('rDiameter').AsFloat := 0.12; 
> ...
> zData.Post;
>
> Then, at the table, I see that the values are stored as follows: 
>
> rTitle = *0.1199*
> rDiameter = 0.12 
>
> Do not know why rTitle is 0.1199 instead of 0.12 
> I need the saved values are accurate. 
> I've tried AsFloat, AsCurrency, Value, always with the same result.
A suggestion: Try to alter your column from: rTitle DECIMAL(8,4) not
null *to* rTitle DECIMAL(8,2) not null.
I think the rounding occurs because you have four numbers after the
decimal point. If you need that precision, you need to input 0.1200 for
your database to store it at that exact value

I tried your case in PostgreSQL, and it store as is without the rounding
problem.

>
> Any idea?
>
> Tks. 
> Daniel.
>
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus@lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to