02-10-2023 06:21 AM
Hello,
i noticed an error in my script using the in-build Round() function. Why do these 2 statements output the same result (at least for me using DIAdem 2022 Q4):
Logfiledel
Logfilewrite Round(1.5) ' Output = 2
Logfilewrite Round(2.5) ' Output = 2 (?)
Is this a bug or what could be the problem? Obviously Round(2.5) should output 3 and not 2.
Thanks in advanced for your support!
Solved! Go to Solution.
02-10-2023 09:31 AM
Microsoft follows IEEE 754 standard - round half to even. So it is working perfectly to the standard.
02-13-2023 12:30 AM
Thanks for your reply.
Is there an in-build function to round 'mathematically', which means:
02-13-2023 09:17 AM
The built-in rounding in VBS is just that one.
Some options:
1. Try:
Call LogFileWrite(FormatNumber(1.5, 0))
Call LogFileWrite(FormatNumber(2.5, 0))
2. You can implement your own logic for rounding
3. DIAdem has built in whole channel rounding:
You can record it to get the script with the needed options