Do you know the difference between rounding a number commercially and rounding it mathematically? Notes does...
This is, why in Formula @Round(0.5; 1) equals 1, but the equivalent in LotusScript round(0.5, 0) equals 0...
Wonder if round(1.5, 0) equals 1? No, the result is...: 2
The reason is, that there are different agreements on how to round a number. Most known is the commercial rounding, implemented in Formula language: if a number is in the exact middle, the number is always rounded up.
But in cases where numbers must be equally distributed, mathematical rounding is used. And this is implemented in LotusScript.
If a number is in the exact middle, mathematical rounding rounds to the next *even* number: round(0.5, 0) equals 0, round(1.5, 0) equals 2, round(2.5, 0) equals 2 (sic!) etc.
There might be an easier way to make LotusScript round commercially (e.g. using evaluate), but this function works for me:
Function roundCommercially(inputDbl As Double, dec As Integer) As Double
Dim checkNb As Integer
checkNb = Int(inputDbl * 1/ (10 ^ (dec + 1)))
If checkDbl / 2 = Int(checkDbl / 2) Then ' even number
roundCommercially = Round(inputDbl + 1 / (10 ^ (dec + 2)), dec) ' add a little bit behind the .xxx5, to force rounding up
roundCommercially = Round(inputDbl, dec) ' round as usual
About the Author
Marcus Foerster works
as Systems Architect for Pentos AG in Munich, Germany. His focus lies on
the application side, creating collaboration systems for users, groups
and enterprises to get their daily work done. This approach includes
integrating complex workflows with intuitive user interfaces, using
Lotus Notes/Domino with Adobe Flex and other Web technologies.
more in Marcus' blog: http://marcus.foerster.com/blog