Link to home
Start Free TrialLog in
Avatar of MRDELPHI
MRDELPHI

asked on

delphi

Hi All:
I would like to round up some number to three decimal places

59.0625 ===> 59.063
I've try formatcurr, Format('%.3n', [59.0625]), Format('%.3f', [59.0625]) but the result is incorrect
Avatar of Thommy
Thommy
Flag of Germany image

Why do you think the result is incorrect????

The fourth decimal place is 5 and so the third decimal place is rounded up from 2 to  3.
So everything is OK...
Avatar of jimyX
jimyX

What result do you get?
Because I get "59.063" when I use Format('%.3n', [59.0625]).
ASKER CERTIFIED SOLUTION
Avatar of jimyX
jimyX

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm absolutely sharing jimyX's opinion...
jimyX is right - depend on original source. But if you want to have decimal number rounded....there is delphi function SimpleRoundTo.

   num := SimpleRoundTo(3.566, -3); //round to 3 dec. pl.

Open in new window

Avatar of MRDELPHI

ASKER

The Source of this number is equation result the calculation of some tax as following
tax:=salary*insurancepercentage;
tax:=1575*0.0375;
tax:=59.0625;
i would like the result as tax:=59.063
Ok:
I've found the perfect way to do that
tax=:=(1575*3.75)/100
Format('%.3n', [tax])

Thank you for all participate
Thank you very much