The MOD operator documentation in online help contains the following: " Example: Sub ExampleMod Print 10 Mod 2.5 ' returns 0 ... End Sub" However 10 Mod 2.5 actually returns 1, not 0. *Either the code or the documentation is wrong.* FWIW OO 4.1.1 behaves the same. The "Libre Office Basic Guide (v. 3)" documents MOD - modulo operation (calculation of the remainder of a division) Nowhere is there any mention of rounding or truncation of the arguments, but the second arg appears to be munged somehow -- but not consistently. 10 Mod 2.5 returns 1 (contrary to the docs), which is what you would expect if 2.5 were rounded to 3. However 10 Mod 0.9 produces a "Divide by zero" error, which implies truncation toward zero rather than rounding. STEPS TO REPRODUCE: 1. Open the Basic IDE on some module to allow entering new code (For example: Open a new spreadsheet; Tools->Macros->Organize Macros->LibreOffice Basic Click "Untitled 1" (or the document name); Click NEW; IDE Editor opens ) 2. Paste the following test sub at the top of the module: sub bugtest print "10 Mod 2.5 = " ; 10 Mod 2.5 end sub 3. Press F5 or click the "Run Basic" icon ACTUAL RESULT: 1 DOCUMENTED RESULT: 0
On pc Debian x86-64 with master sources updated today, I could reproduce this.
*** This bug has been marked as a duplicate of bug 84435 ***