[Lazarus] Problem rounding values at post

zeljko zeljko at holobit.net
Wed Jun 4 07:11:23 CEST 2014


On 06/03/2014 10:39 PM, 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.
>
> Any idea?

That's pretty strange. I'm using zeos + postgresql with numerics and 
never had such problem. Are you sure that rTitle field is numeric ? If 
it's float then it could be something like 0.1199.

zeljko






More information about the Lazarus mailing list