Posted on 2003-11-26
Here is an easy one.
I started a new Delphi project and put 2 buttons on the empty form.
On the OnClick event of Button1, I inserted this line of code:
showmessage(FormatCurr('0.00',2.955) + #13 + FloatToStr(RoundTo(2.955,-2)));
On the OnClick event of Button2, I inserted this line of code:
showmessage(FormatCurr('0.00',3.955) + #13 + FloatToStr(RoundTo(3.955,-2)));
The only difference between the two lines is the constant float number. 2.955 for button1 and 3.955 for button2.
I ran the app and clicked on the buttons.
Button1 gave me this:
Button2 gave me this:
Why can't it be the same ?
What I need is to round 3.955 to 3.95 and 1.755 to 1.75 (while still rounding 3.956 to 3.96 and 1.755 to 1.76). How do I do that ?