Hi,
in some cases the function Round() gives wrong result. For example:
0.82*0.15*115.00 = 14.145
but round() of these value:
Round(0.82*0.15*115.00 ,2) gives 14.14 instead 14.15 !!!
Piotr
Malfunction round()
Re: Malfunction round()
Update:
when you round intermediate results, like:
Round(Round(0.82*0.15,4)*115.00 ,2)
the result is correct: 14.15
Look like it's again the result of a binary representation of the non-integer value (like 14.15 = 14.1499999999999999999...)
Regards
Piotr
when you round intermediate results, like:
Round(Round(0.82*0.15,4)*115.00 ,2)
the result is correct: 14.15
Look like it's again the result of a binary representation of the non-integer value (like 14.15 = 14.1499999999999999999...)
Regards
Piotr
-
- Posts: 479
- Joined: Wed Jan 27, 2010 10:25 pm
- Location: Berlin Germany
Re: Malfunction round()
That is the reason, i use the function roundZ() for some years:
Code: Select all
Function RoundZ(nValue)
Return (Round(Round(nValue, 4), 2))
_______________________
Best Regards
Wolfgang
Best Regards
Wolfgang
Re: Malfunction round()
Wolfgang,
these function don't solve problem. For example:
x=14.144966
Round(x,2) will be 14.14
and RoundZ(x) will be 14.45.
To get the correct result of multiple multiplication of a non-integer values, we need round after each multiplication.
Piotr
these function don't solve problem. For example:
x=14.144966
Round(x,2) will be 14.14
and RoundZ(x) will be 14.45.
To get the correct result of multiple multiplication of a non-integer values, we need round after each multiplication.
Piotr
Re: Malfunction round()
Hi all,
I found that these problem was described under PDR 6678. When I add in ARC file under VERSION:
"FPU_ControlWord" = "626"
this problem was solved.
Regards
Piotr
I found that these problem was described under PDR 6678. When I add in ARC file under VERSION:
"FPU_ControlWord" = "626"
this problem was solved.
Regards
Piotr
Re: Malfunction round()
Hi all,
I found another solution. This easy trick solve the problem
instead Round(x,n) ---> Round(Val(Str(x)),n)
Regards
Piotr
I found another solution. This easy trick solve the problem
![Smile :)](./images/smilies/icon/smile.gif)
instead Round(x,n) ---> Round(Val(Str(x)),n)
Regards
Piotr