calc: 'MOD' in sheet vs. 'MOD' in macro - want to drive me crazy?

oh, we miss each other, the ‘suffer from fp-rounding’ does not refer to this question, but to the project where this question appeared, the =75,293-int(75,293) does not refer to this problem, but to the possible assumption that wrong punctuation is responsible for this problem,
the problem for this question is if mod of a fraction should result with fraction, or be rounded away, and that it’s different between sheet and basic

Hello,

quote from the macro bible

and that is indeed different from the formula mod function

https://wiki.openoffice.org/wiki/Documentation/How_Tos/Calc:_MOD_function

To get the remainder in the macro you will most like have to use DIVISION with SUBTRACTION.


Hope that helps.

To show the community your question has been answered, click the ✓ next to the correct answer, and “upvote” by clicking on the ^ arrow of any helpful answers. These are the mechanisms for communicating the quality of the Q&A on this site. Thanks!

Have a nice day and let’s (continue to) “Be excellent to each other!”

@igorlius: thanks, i think you are right, the implementation in ‘basic’ and ‘formula’ is different,
in a way i expected that it is mentioned somewhere in the manuals, and that i am ‘wrong!’ with my anger / wonder because i ignored ‘rtfm’ …
but seriously, which programmer always looks up every function before using it, and who expects such a different way of working for the same functionality in a system?
really thanks for the help, my perplexity was so big that i didn’t feel like doing research because of my frustration,
these things are not only used by LO experts, but by ‘normal people’, why do we annoy them with such traps?

Good question.
If i had to guess, i would say somthing like this happend:

Two programmers/teams thought their mod implementation was the better aka most fitting.
Or they just did not know about the other.

@igorlius - your link perfectly describes how this probably happened :wink:

You can call the Calc Cell functions if you need it in your macro code:

Function CellMod(theRealNum as double, theDivider as integer) as double
     dim oFunctionaccess
     dim arg as Variant
    	oFunctionAccess = createUnoService( "com.sun.star.sheet.FunctionAccess" )
    	arg =array(theRealNum, theDivider)
     CellMod = oFunctionAccess.CallFunction("MOD",arg)
End function

And you can use the Basic MOD in the Cells:

Function iMod(theIntNum as integer, theDivider as integer) as double
 iMod = theIntNum mod theDivider
End function

This might be the easiest way to achieve the exact same behaviour, without any surpises. Nice.

yeah, had seen that and it works, but why has calc always to be so complicated?

…What is “so complicated” in the Calc?

@Zizi64: complicated … you haven’t yet spotted that? stay happy or continue reading … copy 'n paste, macro language, bug handling, 12 years unresolved bugs, evaluation of ‘-’, autofilter issues, not standard conform files, slowdown issues with comments, function wizard, undo issues, wrong calculations, ‘mod’ in formula <> ‘mod’ in macro, fp-rounding issues, autocalculate exclusions, not all functions recalcuated, parallelized computing issues (open-CL and threaded) … and some more … it’s not that calc is ‘bad’, it’s better than ex$el imho, but sometimes but sometimes i despair when i think how good it could actually be … and how hard it is to get anything forward …

“copy 'n paste,”: What is the problem with this function? Note: There is not (never was and never will be 100% compatibility between the different file formats, document types and the formatting methods. Therefore always better to paste the formatted texts from a foreign source “as unformatted text” to your documents. It is true for every editor software.

“not standard conform files”: The only one REALLY standardized file format for office documents is the ODF. The binary MS file formats never was standardized, and they have lots of poorly documented subversions. The “Standardized” OOXLM file format has a Strict version, and a Transitional one, what is often modified by MS without documentation.

"‘mod’ in formula <> ‘mod’ in macro, ": The original MOD operator was created for dividing integer by integers - nothing more. You can use the “extended” version with pure integers too.

“fp-rounding issues,”: The IEEE 754-2008 standard for the floating point numbers is independent from the office suites. Maybe the Excel rounds the results without inform you about the changing of the result. The LO will not rounding the results instead of you. It is your job, it is your responsibility. The LO will display the BEST available result by default.

“parallelized computing issues (open-CL and threaded)”: Just switch OFF this feature if your Videocard has not proper capability for this feature.

“not all functions recalcuated,”: Yes, It only recalculates functions whose at least one input parameter has changed. But you can enforce the full recalculation manually.

Conclusion:

Do not use the LibreOffice if it is not appropriate for you.

hello @Zizi64, don’t try to be a ‘fanboy’, considering the effort i invested in calc problems and quality i’m a fan as well, perhaps the bigger one,
reg. the points, i know about them, but stating copy 'n paste is working fine while i’m maintaining a incomplete! list with 49 bugs filed about it, none of them resolved except marking as duplicate, just look in ‘bugs’ … is not an improvement of the problem, similar yields for the other points …
‘The LO will display the BEST available result by default.’, i wish it would be like that, it isn’t, see https://bugs.documentfoundation.org/show_bug.cgi?id=133840, https://bugs.documentfoundation.org/show_bug.cgi?id=128312, and https://bugs.documentfoundation.org/show_bug.cgi?id=131312,
criticism is annoying, but criticism is also necessary, you won’t enjoy a calc as good as it is if not many hard-working people had invested a lot of work to spot, substantiate and document errors,

Me and our little company using the LibreOffice since the forking date without larger problems.
Yes, I know it: there are bugs (older ones and newer ones, smaller and bigger ones too).

The vast majority of problems come from such users,

  • who use the Office program as if it were a mechanical typewriter …

  • who use the LibreOffice as if it were MS Office without the “Styles” function … They expected to have an
    MS Office clone in all properties.

  • who think that LibreOffice is a paid product and that for their “money” they are entitled to and error-free
    product.

  • they don’t realize it’s a community where you can “get and give” something.

@Zizi64: but now it really becomes OT:

why do I always let myself get caught up in my tendency to discuss and question fundamental things?

‘a community where you can “get and give” something.’

that’s right, but!:

such a community is necessarily heterogeneous, and thus members have different views, may they have, must they even have, it is a drive for progress,

and you belong to those who think ‘the users are to blame’, I belong to those who think ‘the users have to grow into the community’, and you should not make it unnecessarily difficult for them,

you to those who think the claim ‘typewriter’ is primitive / wrong, I to those who think such claims should be easy to fulfill, why is it so difficult for us?

you to those who think we are independent of M$, I to those who see the problems that (too?) much importance is attached to compatibility, but that is mainly used to defend errors,

… you to those who think the demands of non-paying users should be ignored, I to those who think if you lure users with sayings like ‘the office suite you always wanted’, you create a demand that you should face up to,

you to those who think the users are the problem, I to those who think ‘fundamental mistakes unsolved for 12 years’ also contribute to it,

you to those who think too much ‘pretension’ is the problem, I to those who think too little potent developers are also a problem,

you to those who think ‘most of it is ok’, I to those who have talents to find faults where others think it is impossible that there are any,

you to those who are sensitive to criticism or consider it harmful and therefore ‘fight’ it, I to those who think that ‘glossing over’ is wrong, the problems have to be put on the table and worked off,

and so on …

… it would be important that we don’t spend too much time arguing, but see the progress of the project as our highest goal, tolerate each other even if we are different, work ‘on the thing’, accept that there is still a lot to do … and there I may also say ‘pff’ if something unruly has crossed my path again …

if we need to discuss further you can find my mail address at 'bugs

P.S. I am aware that these comments are ‘ot’ for the question, but it had to be said!

I am not a developer, so I can use the LO only on ‘As is’ base. I have adapted (from foreign sources) hundreds of macro functions and subroutines for our calculations and other needs, (and I wrote other hundreds after studying the API ) but i can not modify the source code of the LO.

Therefore I am trying to get the best performance from the existing versions. I never install the Fresh version for daily works (because I had read the warnings on the download page), We never use the MS file formats our own documents, and we store the documents (what must be send) in ODF file formats and only a copy will be converted and sent in some other file format.

All of editor softwares enforce its own file format. For example we are using CAD softwares, but not the well known AutoCAD. Our CAD softweres can export into AutoCAD file format, but it is better to use the native file formats - if we want re-edit them in the future - without compatibility problem.
An expert user must choose the apropriate tool to the job. People who exclusively must use the MS file formats (in some reason), must buy the MS Office. I can not imagine if in the future will be 100% compatibility between the different file formats. This is not in Microsoft’s interest.