Delphi Chart With 2 Decimal Places
I have to selected some column data from a database table and make this data with two decimal places only. I see this
What is that #9?
How can I deal with the data I selected to make it only keep two decimal places?
I am very new to Delphi.
Thanks!
Mar 01, 2017 Retain 2 decimal points on float when converting to string delphi. Browse other questions tagged string delphi decimal or ask your own question. 2 years, 3 months ago. 2 years, 3 months ago. Difference between decimal, float and double in.NET?
5 Answers
#9
is the character with code 9, TAB.
If you want to convert a floating point value to a string with 2 decimal places you use one of the formatting functions, e.g. Format()
:
#9
is the tab character.
If f
is a floating-point variable, you can do FormatFloat('#.##', f)
to obtain a string representation of f
with no more than 2 decimals.
The internal float format routines only work with simple numbers > 1
You need to do something more complicated for a general purpose decimal place limiter that works correctly on both fixed point and values < 1 with scientific notation.
I use this routine
So, with digits=2, 1.2349 rounds to 1.23 and 1.2349E-17 rounds to 1.23E-17
Andy kAndy k