12.08.2019»»понедельник

Delphi Chart With 2 Decimal Places

12.08.2019
    85 - Comments
Hi, just learning Excel here (and statistics as well) and have an issue with a simple pie chart. The data entered is in the form x.x, so 42.4, 5.5, 18.3, etc. When displaying the pie chart, Excel rounds all of these to the nearest integer. If there are multiple entries that are rounded up, the last entry has to be rounded down significantly to conform to 100%, or vice versa. In the example, the last entry was 42.4, and it gets rounded down to 41% on the pie chart.
I can not see any way to allow Excel to show anything other than integer values on the pie chart. Surely there must be a way to show decimal points of one's choosing?
Delphi

Delphi Format to 2 decimal places. Some of the results of this function show '9.666' and I would like that to show as '9.67'. From novice to tech pro — start learning today. Business Communication By: Martin VanDerSchouw.

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!

Marco
47.4k11 gold badges111 silver badges134 bronze badges
spsplispspli
1,3756 gold badges36 silver badges67 bronze badges
Round answers to 2 decimal places

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():

David HeffernanDavid Heffernan
529k35 gold badges866 silver badges1260 bronze badges

#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.

Andreas RejbrandAndreas Rejbrand
74.2k6 gold badges220 silver badges310 bronze badges

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 k

Round Answers To 2 Decimal Places

Andy k
5631 gold badge6 silver badges18 bronze badges
Brian Tompsett - 汤莱恩
4,38214 gold badges40 silver badges107 bronze badges
RTSRTS
amytrajghimireamytrajghimire

Rounded To 2 Decimal Places

Not the answer you're looking for? Browse other questions tagged delphidecimal or ask your own question.