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
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
What result do you get?
Because I get "59.063" when I use Format('%.3n', [59.0625]).
Because I get "59.063" when I use Format('%.3n', [59.0625]).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
ASKER
The Source of this number is equation result the calculation of some tax as following
tax:=salary*insuranceperce ntage;
tax:=1575*0.0375;
tax:=59.0625;
i would like the result as tax:=59.063
tax:=salary*insuranceperce
tax:=1575*0.0375;
tax:=59.0625;
i would like the result as tax:=59.063
ASKER
Ok:
I've found the perfect way to do that
tax=:=(1575*3.75)/100
Format('%.3n', [tax])
Thank you for all participate
I've found the perfect way to do that
tax=:=(1575*3.75)/100
Format('%.3n', [tax])
Thank you for all participate
ASKER
Thank you very much
The fourth decimal place is 5 and so the third decimal place is rounded up from 2 to 3.
So everything is OK...