Problem rounding values at Post lazarus / 16-Databases ---------------------------------------------------------------------- derles · 2014-06-03 20:36 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: Code: [Select]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. ---------------------------------------------------------------------- derles · 2014-06-03 21:35 Strange. I tried many values and y found this happens: ... inserting 0.06 stored as 0.0599 0.07 --> 0.07 0.08 --> 0.08 0.09 --> 0.0899 0.10 --> 0.10 0.11 --> 0.11 0.12 --> 0.1199 0.13 --> 0.13 0.14 --> 0.14 0.15 --> 0.1499 0.16 --> 0.16 0.17 --> 0.17 0.18 --> 0.1799 ... could be a bug ? ---------------------------------------------------------------------- mangakissa · 2014-06-04 09:10 It depends. I don't  have ZEOS and test it with SQLDB. Used two databases: MySQL and Firebird. First I inserted a record outside Lazarus. Thats seems to be okay. Than created a small example in Lazarus and inserted in both databases. All these results were the same. So it could be a problem in ZEOS. Does you application give you the wrong values from the table after inserting? ---------------------------------------------------------------------- derles · 2014-06-04 11:06 I read the table from my application and from FlameRobin. Wrong values in both cases. ---------------------------------------------------------------------- miab3 · 2014-06-04 11:59 @derles, For ZEOS 7.2 (R3130): http://svn.code.sf.net/p/zeoslib/code-0/branches/testing-7.2/ This effect is not observed. Lazarus 32/64(fpc 2.7.1) on Windows7-64(CodeTyphon ver 4.80), Firebird 2.5.3. Michal ---------------------------------------------------------------------- marcov · 2014-06-04 18:26 See if /firebird/ has a currency type. Probably DECIMAL is floating point, and not all numbers and common fractions can be exactly represented in floating point. ---------------------------------------------------------------------- BigChimp · 2014-06-04 18:46 See the thread on the mailing list for a post about what Firebird decimal is in dialect 1 and 3...