[Lazarus] Problem rounding values at post

Allan E. Registos allan.registos at smpc.steniel.com.ph
Thu Jun 5 01:39:15 CEST 2014


On Thursday, 05 June, 2014 02:33 AM, Daniel Erles wrote:
> Yes, I tried with round too. 
>
> Now I understand the problem, thanks to the explanation of Mattias. 
> But I could not find a solution yet. 
>
> The problem only occurs when I insert data using INSERT and POST
> functions. 
> I tried creating an SQL INSERT, and running it with ExecuteQuery (),
> and the values are saved correctly.
I think you can try to do SQL by hand and connect to Firebird directly
with your SQL queries as a workaround without using Zeos or sqldb.
> The problem apparently is not in Firebird, but in ZEOS
> classes implementation, or their ancestors. 
>
> I think maybe I'll look for a different approach to solve my problem,
> perhaps with the use of BCD fields. We'll see.
>
>
> 2014-06-04 11:55 GMT-04:00 Poncho Velázquez
> <poncho-velazquez at hotmail.com <mailto:poncho-velazquez at hotmail.com>>:
>
>     Hi Daniel,
>
>     have you tried to use function Round in te assignment of the value??
>
>     Regards
>     Poncho
>
>     ------------------------------------------------------------------------
>     Date: Tue, 3 Jun 2014 16:39:30 -0400
>     From: derles at gmail.com <mailto:derles at gmail.com>
>     To: lazarus at lists.lazarus.freepascal.org
>     <mailto:lazarus at lists.lazarus.freepascal.org>
>     Subject: [Lazarus] Problem rounding values at post
>
>
>     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. 
>
>     Any idea?
>
>     Tks. 
>     Daniel.
>
>     -- _______________________________________________ Lazarus mailing
>     list Lazarus at lists.lazarus.freepascal.org
>     <mailto:Lazarus at lists.lazarus.freepascal.org>
>     http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
>     --
>     _______________________________________________
>     Lazarus mailing list
>     Lazarus at lists.lazarus.freepascal.org
>     <mailto:Lazarus at lists.lazarus.freepascal.org>
>     http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
>
>
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20140605/1099b18e/attachment-0003.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4267 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20140605/1099b18e/attachment-0003.bin>


More information about the Lazarus mailing list