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
Cheers
Sandra
Related Topics
Delphi/Lazarus: 3 Ways to round a Number to X Decimal Places
Tutorial | 7 Comments
PHP: Write Output of a Script into Variable
Tutorial | 0 Comments
MySQL: Line Breaks in MySQL
Tip | 0 Comments
PHP: Rounding Numbers
Tutorial | 0 Comments
Delphi/Lazarus: Display current Date and Time
Tip | 0 Comments
Delphi/Lazarus: Only allow Numbers in TEdit
Tip | 0 Comments
PHP: Send Output of a Script by Mail
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.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
There are many ways for doing that. One way is to use the function FormatFloat. You can rewrite your code to:
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