09-15-2022 10:24 AM - edited 09-15-2022 10:26 AM
In my TestStand 2019 application the number 0.18325, with 4 decimal digits (format string %.4f), is rounded to 0.1832. I would expect 0.1833,
Could anyone help me, please?
Thanks in advance, and best regards!
Alessia
Solved! Go to Solution.
09-15-2022 10:40 AM
It would be because it would use Bankers rounding where a number in the middle of two numbers is rounded to the nearest even number.
So, anything at x.5 will use this particular case.
09-15-2022 11:06 AM
Also note that Banker's Rounding is actually the IEEE recommended rounding due to statistical analysis.
09-15-2022 12:05 PM - edited 09-15-2022 12:05 PM
Bankers rounding is only part of the story here and is probably not the correct explanation in this edge case.
A format of %.4f is a purely cosmetic property. Assuming the underlying numeric is in DBL representation, the closest number to 0.18325 that can be represented correctly in binary is 0.183249999999999996 and thus will be rounded to 0.1832 in any typical rounding scheme.
Where does the value come from?
09-16-2022 09:12 AM
@altenbach:
This is a limit value for a Numeric Limit Test step, and has been calculated as follows:
0.175+0.003+0.175*0.03