Recent

Author Topic: FIREBIRD + ZEOS Decimal fields round issue  (Read 1660 times)

Mando

  • Full Member
  • ***
  • Posts: 181
FIREBIRD + ZEOS Decimal fields round issue
« on: August 04, 2015, 08:10:20 pm »
Hi, all.


My project uses a Firebird DB. Some tables with float fields, defined as DOUBLE PRECISSION.
I use ZEOS to access that DB. The values of these fields not are displayed correctly in DBControls (DBEdit, DBGrid)

If I enter 20.40, it is displayed 20, when I enter 20.56 it is displayed 21.
That is, it is rounded to integer.
This behavior only occurs when the (rounded) value is greater than 10, and only with ZEOS controls.

0.50 -> 0.50
1.56 -> 1.56
9.99 -> 10
12.65-> 13 ... AND SO...


From ZEOS, tell me that can be a FPC bug.
Does anybody have the same problem?

 
Regards.

Windows XP/7
Lazarus 1.4.2 svn 49524 - FPC 2.6.4
ZEOS 7.1.4-stable
FIREBIRD 2.5.3

I attached a demo project.



miab3

  • Full Member
  • ***
  • Posts: 145
Re: FIREBIRD + ZEOS Decimal fields round issue
« Reply #1 on: August 04, 2015, 11:13:57 pm »
@Mando,

Add Button1 with:

Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
  var I:integer;
begin
for I := 0 to ZQuery1.FieldCount - 1 do
  case ZQuery1.Fields[I].DataType of
    ftFloat, ftBCD, ftSmallint, ftInteger, ftWord:
        TNumericField(ZQuery1.Fields[I]).DisplayFormat := '0.##########'; //'#.##'
    ftCurrency:
        TNumericField(ZQuery1.Fields[I]).DisplayFormat := ',0.00';
  end;
end;
   
and see what happens.

Windows 7-32
Lazarus 1.4.2
ZEOS 7.2 svn 3638
FIREBIRD 2.5.4

Michal
« Last Edit: August 04, 2015, 11:16:30 pm by miab3 »

 

TinyPortal © 2005-2018