11 Vote

Delphi: Format Numeric Output with 2 Decimal Places

Question by Sandra Poderon | 2021-01-07 at 07:20

Hello community

Please lend a hand :)

I have this line :

Memo10.Text := FloatToStr(round(Memo29.Value)) + '$';

This results is rounded : 25

How to re-write it to result with 2 decimals : 25,16



26 Votes

There are many ways for doing that. One way is to use the function FormatFloat. You can rewrite your code to:

Memo10.Text := FormatFloat('0.00', Memo29.Value) + '$';

FormatFloat takes a formatting string (here 0.00 for 2 decimals) and the value you want to show.

If you want to pass the value as string, you can use FormatFloat('0.00', StrToFloat('25.161234')).
2021-01-07 at 14:24

ReplyPositive Negative

Related Topics

PHP: Rounding Numbers

Tutorial | 0 Comments

PHP: Current Date and Time

Tutorial | 0 Comments

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.


Ask your own question or write your own article on askingbox.com. That’s how it’s done.