MrJackFrost wrote:I'm sorry but I think that this is also incorrect. You need to find the closest multiple of three that is less than -23 (this goes for when you are modding both a positive or negative number). -21 > -23 so -21 would not be the number to use. The closest multiple of 3 that is less than -23 is -24 because -24 < -23. Then -23 - (-24) = -23 + 24 which = 1.
I am not suggesting that you are incorrect, I am just trying to find an explanation as to "why" this is happening.
Rainmeter is written in C++, and C++ does modulus division this way (which may go against common mathematical practices). There really is no problem here as we are not going to add a bunch of code just to "fix" something that really isn't broken.
OH, I misread your post, my mistake. I thought you were saying in general modulus division does not work on negative numbers. Okay, so then I have another question, is there a way to make a measure launch a script other then a lua script. For example could I do something along the lines of:
Brian wrote:Rainmeter is written in C++, and C++ does modulus division this way (which may go against common mathematical practices). There really is no problem here as we are not going to add a bunch of code just to "fix" something that really isn't broken.
I'd argue that this is a bug and we should fix it so that the mathematically correct result is returned (especially since it's probably only a few lines of code).
MrJackFrost wrote:Or does this only work for lua scripts?
The Script measure if specifically for Lua scripts.
If you want to launch another type of script, you can just do like this: LeftMouseUpAction=["path\to\your\script\pythonscript.py"] (or you might try LeftMouseUpAction=["pythonscript.py"])
This is assuming you are on the latest beta, and your system is set up to run python scripts through the command line. If your system is not set up that way, you can try launching the program that runs the script like this: LeftMouseUpAction=["path\to\your\pythonscript\python.exe" "pythonscript.py"]
(Since I do not use python, I can not confirm this will work)
poiru wrote:I'd argue that this is a bug and we should fix it so that the mathematically correct result is returned (especially since it's probably only a few lines of code).
Haha, thanks for all your responses! Ill just handle all the calculations in Python for the mean time and I'll keep checking back to this thread to see if there are updates . Again, thanks for your replies!
MrJackFrost wrote:Haha, thanks for all your responses! Ill just handle all the calculations in Python for the mean time and I'll keep checking back to this thread to see if there are updates . Again, thanks for your replies!
Just to be clear, only Lua is supported in Rainmeter in a Measure=Script.
The modulus works differently in some programming languages than it works in its mathematical definition. Sometimes you want the one solution, sometimes you want the other one, depending on your application. You just have to work around if a system only provides one and not the other.
I believe the mathematical definition is designed so you get the same result when adding or subtracting a multiple of the number you are taking the modulo with. For example 23 mod 3 = 2, and (23-14*3) mod 3 = 2. This definition must not care about your number being positive or negative.
I think this is implemented differently in some programming languages because of the way (integer) numbers are represented in a computer. The "incorrect" version you find in C++ and the like is faster and easier to compute on a cpu while still giving a meaningful result. If you need the correct mathematical one you have to convert the result yourself.
EDIT: Sorry if this post contains redundant information. I didn't notice there were two pages.