function roundDot05 (Value : real) : real;
function getModifier(ModValue : real) : real;
begin
if ModValue < 0.25 then
result := 0
else if ModValue > 0.75 then
Result := 1
else
Result := 0.5;
end;
begin
Result := (Int(Value * 10) + getModifier(value*10 - Int(Value * 10))) / 10
end;
0
luisseixasCommented:
It's easy. Multiply it by 20, round it, and then, divide it by 20. The results are:
13,02 = 13,00
13,03 = 13,05
N -> Your real number
R -> Result
R := round(N*20)/20;
0
Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.
function round05(a:real):real;
begin
round05:=round(a*20)/20;
end;
0
brownberryCommented:
This solution helped me. I was trying to do similar rounding...to the nearest 1/4 lb, 1/2 lb, 1/0 lb for calculating weight for shipping charges. Using the example, I was able to write my solution using Cobol. It would be nice to know if there is an API that does this?
0
Featured Post
We value your feedback.
Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!
Result := Round(your_number*10) / 10;