Bug 84435 - Mod operator does not deal with decimals as described in help
Summary: Mod operator does not deal with decimals as described in help
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: Other All
: medium normal
Assignee: Julien Nabet
URL:
Whiteboard: target:5.0.0 target:4.4.4
Keywords:
: 89603 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-09-28 21:30 UTC by Stanislav Horacek
Modified: 2021-04-05 06:38 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stanislav Horacek 2014-09-28 21:30:23 UTC
Modulo operator in Basic cannot deal with decimal numbers. Whereas the help text states:
Print 10 Mod 2.5 ' returns 0

actual result of 10 Mod 2.5 is 1 (2.5 is apparently rounded up to 3).
(Contrary to this, MOD function in Calc returns 0 in this example.)

I'm not sure what behaviour should be considered as reference. In any case, either Mod operator or its description in help should be corrected.

Tested on 4.2.6 and 3.5.4, probably inherited from OOo.
Comment 1 Cor Nouws 2014-10-18 12:03:28 UTC
Indeed present in 3.3.0 already
thanks!
Comment 2 Julien Nabet 2015-02-24 20:34:15 UTC
*** Bug 89603 has been marked as a duplicate of this bug. ***
Comment 3 Julien Nabet 2015-02-24 20:49:59 UTC
Not dup of fdo#50299 since we just talk about doc here which indicates something different from what LO really does.

BTW, in Calc part, Mod(10;2.5) returns 0
Comment 4 Julien Nabet 2015-02-24 22:04:52 UTC
Just for information, I submitted this patch for review: https://gerrit.libreoffice.org/#/c/14611/
Hope it'll be ok :-)
Comment 5 Commit Notification 2015-04-30 14:27:53 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=0f79a5ff07e5b392044726b657998561cbe97fda

tdf#84435: Mod operator does not deal with decimals as described in help

It will be available in 5.0.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2015-04-30 14:33:28 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-4-4":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=b51a30504ec3c00b0bad616817471aa01918e06e&h=libreoffice-4-4

tdf#84435: Mod operator does not deal with decimals as described in help

It will be available in 4.4.4.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 7 Stanislav Horacek 2015-05-14 21:13:37 UTC
Checked in master, everything as expected. Thanks, Julien, nice work!
Comment 8 Julien Nabet 2015-05-14 21:16:24 UTC
You're welcome :-)
Following your feedback, let's put this one to VERIFIED
Comment 9 Mike Kaganski 2021-04-05 06:33:41 UTC
This was completely NAB (and in fact, the underlying problem was tdf#141200, which was a *documentation* problem). The change was wrong. It created a regression tdf#141201 :-)