Formatting dbEdits lazarus / 16-Databases ---------------------------------------------------------------------- eshjim · 2016-08-12 15:58 Having successfully completed my first Lazarus database project which did not contain numerical data, I am now on to my second which very much does!  Much has been asked and written about display formats of TEdit boxes, but not so much that I can understand about TDbEdits. I have a REAL-type field in an existing sqlite3 database with an entered (not calculated in any way) value of 18514.19. Placing a dbEdit component linked to that field on my form displays a value of 18514.189999999999. As other field values will depend on this figure, I am assuming that those values would be calculated on the database number rather than the displayed number - I realise that the difference is minimal but it could have a cumulative impact after a period of use. My questions are a) does anyone know why the actual and displayed figures differ and b) what is the best way of formatting the dbEdits to display the correct amount without affecting the underlying database? Any help much appreciated. ---------------------------------------------------------------------- LacaK · 2016-08-12 17:01 Ad a) read about how floating point numbers are stored in memory (they are not exact numeric) Ad b) try look at TFloatField.DisplayFormat or TFloatField.Precision ---------------------------------------------------------------------- eshjim · 2016-08-12 22:17 Quote from: LacaK on August 12, 2016, 07:01:34 pmAd a) read about how floating point numbers are stored in memory (they are not exact numeric) Ad b) try look at TFloatField.DisplayFormat or TFloatField.Precision Thank you @LacaK for pointing me in the right direction. Using the following code correctly displays the data: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TFloatfield (quSummary.FieldByName('OpeningBalance')).DisplayFormat:='0.00'; Bearing in mind that I have multiple similar fields in the dataset, is there a quick way to code the DisplayFormat for them all at once or must they be individually coded as above? ---------------------------------------------------------------------- mangakissa · 2016-08-16 06:51 Yes. Make the fields persistent by loading all the fields in a fieldeditor and set the display @designtime ---------------------------------------------------------------------- eshjim · 2016-08-16 09:57 Quote from: mangakissa on August 16, 2016, 08:51:31 amYes. Make the fields persistent by loading all the fields in a fieldeditor and set the display @designtime Thanks for that. Where I was going wrong at design time was adding the fields from an active query via the FieldDefs property. instead of right-clicking the query and bringing up the Fields Editor.