It is currently April 26th, 2024, 2:18 am

[BUG] Calc RANDOM with Subtraction and Parentheses

Report bugs with the Rainmeter application and suggest features.
User avatar
iNjUST
Posts: 117
Joined: June 20th, 2012, 12:44 am

[BUG] Calc RANDOM with Subtraction and Parentheses

Post by iNjUST »

Currently running r2302 on Windows 8.1 64-bit. I don't have a chance to test with other OS or builds at this moment.

The way the RANDOM constant is defined in Calc, it generates a random number but by default UpdateRandom=0, so after the initial update, the RANDOM value is static. You can throw this value in to a variety of expressions and math functions.

However, when subtraction is used and the Formula is grouped with parentheses, the RANDOM constant becomes dynamic as if UpdateRandom=1 (the value changes every update).

Example Bugged Code:

Code: Select all

[CalcRandom]
Measure=Calc
Formula=(RANDOM-10)
; or, similarly...
Formula=(10-RANDOM)
However, all of these formulas work just fine:

Code: Select all

Formula=RANDOM-10
Formula=10-RANDOM
Formula=(-10+RANDOM)
Formula=(RANDOM+10)
Formula=(RANDOM*10)
Formula=(RANDOM/10)
These are simple examples where the parentheses are unnecessary, but I ran in to this when I was trying to do a combination of operations (e.g. Formula=(RANDOM-10)/10).
Bekarfel
Posts: 217
Joined: May 16th, 2012, 5:38 am

Re: [BUG] Calc RANDOM with Subtraction and Parentheses

Post by Bekarfel »

I have verified this on Windows 7 64bit with Rainmeter 3.2.0 R2311 with the following script

Edit: I have gone through old versions of rainmeter available for download on the website and the first version this bug occurs in is 2.5.0. it does not occur in 2.4.0, or any previous versions tested.

Code: Select all

[Rainmeter]
Update=1000

[MeasureF1]
Measure=Calc
Formula=RANDOM-10
[MeasureF2]
Measure=Calc
Formula=RANDOM+10
[MeasureF3]
Measure=Calc
Formula=RANDOM*10
[MeasureF4]
Measure=Calc
Formula=RANDOM/10
[MeasureF5]
Measure=Calc
Formula=RANDOM**10
[MeasureF6]
Measure=Calc
Formula=RANDOM%10

[MeasureF1a]
Measure=Calc
Formula=(RANDOM-10)
[MeasureF2a]
Measure=Calc
Formula=(RANDOM+10)
[MeasureF3a]
Measure=Calc
Formula=(RANDOM*10)
[MeasureF4a]
Measure=Calc
Formula=(RANDOM/10)
[MeasureF5a]
Measure=Calc
Formula=(RANDOM**10)
[MeasureF6a]
Measure=Calc
Formula=(RANDOM%10)

[MeterS1]
Meter=String
MeasureName=MeasureF1
MeasureName2=MeasureF2
MeasureName3=MeasureF3
MeasureName4=MeasureF4
MeasureName5=MeasureF5
MeasureName6=MeasureF6
MeasureName7=MeasureF1a
MeasureName8=MeasureF2a
MeasureName9=MeasureF3a
MeasureName10=MeasureF4a
MeasureName11=MeasureF5a
MeasureName12=MeasureF6a
Text=subtract %1, add %2, multiply %3, divide %4, power %5, remainder %6, (subtract) %7, (add) %8, (multiply) %9, (divide) %10, (power) %11, (remainder) %12
FontColor=ffffffff
StringEffect=Border
FontEffectColor=000000ff
moshi wrote:there are many Rainmeter skins that aren't really useful, so let's add another one.
jsmorley wrote:I have good news and bad news.
First the bad news. [...] We would be happy to have this happen and would love to work with anyone who is feeling ambitious.
Now the good news.
I lied, there isn't any good news...
User avatar
Brian
Developer
Posts: 2684
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: [BUG] Calc RANDOM with Subtraction and Parentheses

Post by Brian »

@iNjUST: Thanks for reporting!

@Bekarfel: Thanks for doing some simple tests. It helps to narrow down exactly "when" the problem occurred.

This issue has been fixed for the next beta.

-Brian