https://bugs.documentfoundation.org/show_bug.cgi?id=141200

--- Comment #2 from Rafael Lima <[email protected]> ---
There seems to be a difference between MS VBA and LibreOffice Basic on how they
handle fractional remainders:

In Excel VBA, if you run (remainder is rounded to nearest integer):

Sub ExampleMod
    MsgBox 15.1 Mod 5 'Remainder = 0.1; Returns 0
    MsgBox 15.4 Mod 5 'Remainder = 0.4; Returns 0
    MsgBox 15.5 Mod 5 'Remainder = 0.5; Returns 1
    MsgBox 15.6 Mod 5 'Remainder = 0.6; Returns 1
    MsgBox 15.9 Mod 5 'Remainder = 0.9; Returns 1
    MsgBox 16 Mod 5 'Remainder = 1;  Returns 1
End Sub

And in LibreOffice Basic you get different results (even with the "Option
VBASupport 1" flag):

Sub ExampleMod
    MsgBox 15.1 Mod 5 'Remainder = 0.1; Returns 0
    MsgBox 15.4 Mod 5 'Remainder = 0.4; Returns 0
    MsgBox 15.5 Mod 5 'Remainder = 0.5; Returns 0
    MsgBox 15.6 Mod 5 'Remainder = 0.6; Returns 0
    MsgBox 15.9 Mod 5 'Remainder = 0.9; Returns 0
    MsgBox 16 Mod 5 'Remainder = 1;  Returns 1
End Sub

In summary, by looking at the code in [1] (using Mike's references here), this
difference is caused by LO Basic rounding operands before applying the MOD
operator.

I can add a note about that in the Help, as well as a few more examples to
illustrate it better.

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to