After about half an hours frustration I found a small problem with negative numbers. In the math world when you add a negative number to a positive number, it is the same as subtracting the positive form of that number. However, in Rainmeter all you get is a broken formula, even if it's used in a conditional statement.
There is a somewhat easy workaround:
Add a negative
#Var1#<0?#Var2#-ABS(#Var1#):Var2#+ABS(#Var1#)
Subtract a negative
#Var1#<0?#Var2#+ABS(#Var1#):Var2#-ABS(#Var1#)
It is currently May 3rd, 2024, 12:27 am
Negative number problem
-
- Moderator
- Posts: 1931
- Joined: January 29th, 2010, 1:43 am
- Location: Willmar, MN
Negative number problem
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
-
- Developer
- Posts: 1270
- Joined: April 3rd, 2009, 4:31 am
- Location: NC, US
Re: Negative number problem
And I thought I just didn't know how to write the formula... I came up with a similar solution.
-
- Rainmeter Sage
- Posts: 642
- Joined: July 19th, 2009, 5:59 am
- Location: Montreal, QC, Canada
Re: Negative number problem
There's no problem with the math in Rainmeter. Because it's a variable though, what happens is that #Var# gets replaced with the value as though it were actually there. So, if you have Formula=1+#VAR# and the value of #VAR# is -3, then while you think you would get -2 as an answer, the formula actually becomes Formula=1+-3. Rainmeter doesn't know how to deal with the "+-", so the formula fails. To avoid this, just surround your variable names with parenthesis. Formula=1+(#VAR#) should work every time. No need for conditionals.
-
- Moderator
- Posts: 1931
- Joined: January 29th, 2010, 1:43 am
- Location: Willmar, MN
Re: Negative number problem
Nice...I'll have to try that. Will make things a lot easier.
I was actually wondering how things were handled especially when figured out the difference between negative and minus.
I was actually wondering how things were handled especially when figured out the difference between negative and minus.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .