It is currently April 19th, 2024, 6:16 am

Calculation formula for decimal number

Get help with creating, editing & fixing problems with skins
User avatar
tass_co
Posts: 513
Joined: May 4th, 2020, 3:01 pm
Location: Ankara, TURKEY

Calculation formula for decimal number

Post by tass_co »

Hi everyone,

How can i multiply a decimal number?

For example; i want to multiply "7,89" with 8970.

I wrote code but wrong result.
Where am i doing wrong i dont know...

Code: Select all


[MeasureTT]
Measure=Plugin
Plugin=WebParser
URL=[MeasureTop]
StringIndex=2

"MeasureTT=7,89"

[ClcCalc]
Measure=Calc
Formula=(MeasureTT * 8970)

"Result=62790"


And also i tried a different formula. "Formula=(((MeasureTT * 100) * 8970)/100)" but didnt change result..
I don't know where i going from here, but i promise it won't be boring... :great:
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Calculation formula for decimal number

Post by jsmorley »

tass_co wrote: December 11th, 2020, 6:18 am Hi everyone,

How can i multiply a decimal number?

For example; i want to multiply "7,89" with 8970.

I wrote code but wrong result.
Where am i doing wrong i dont know...

Code: Select all


[MeasureTT]
Measure=Plugin
Plugin=WebParser
URL=[MeasureTop]
StringIndex=2

"MeasureTT=7,89"

[ClcCalc]
Measure=Calc
Formula=(MeasureTT * 8970)

"Result=62790"


And also i tried a different formula. "Formula=(((MeasureTT * 100) * 8970)/100)" but didnt change result..
The problem is that Rainmeter is not seeing 7,89 as a decimal number. It is expecting 7.89. So when the string "7,89" is used in a formula, it is seeing the "7", but then ignoring the "," and everything after it. So 8970 * 7 is in fact 62790.

I don't have your WebParser result, but if I fake it up with a String measure, I would do it something like this:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]

[MeasureTT]
Measure=String
String=7,89
Substitute=",":"."

[ClcCalc]
Measure=Calc
Formula=([MeasureTT] * 8970)
DynamicVariables=1

[MeterOne]
Meter=String
MeasureName=ClcCalc
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Result is 70773.

Note that I use the [MeasureTT] string value section variable in the formula, not the number value, since the number value is "7" as I said before. If you use the string value, you get the benefit of the Substitute, which replaces the "," with a ".".
User avatar
tass_co
Posts: 513
Joined: May 4th, 2020, 3:01 pm
Location: Ankara, TURKEY

Re: Calculation formula for decimal number

Post by tass_co »

jsmorley wrote: December 11th, 2020, 12:24 pm The problem is that Rainmeter is not seeing 7,89 as a decimal number. It is expecting 7.89. So when the string "7,89" is used in a formula, it is seeing the "7", but then ignoring the "," and everything after it. So 8970 * 7 is in fact 62790.

I don't have your WebParser result, but if I fake it up with a String measure, I would do it something like this:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]

[MeasureTT]
Measure=String
String=7,89
Substitute=",":"."

[ClcCalc]
Measure=Calc
Formula=([MeasureTT] * 8970)
DynamicVariables=1

[MeterOne]
Meter=String
MeasureName=ClcCalc
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Result is 70773.

Note that I use the [MeasureTT] string value section variable in the formula, not the number value, since the number value is "7" as I said before. If you use the string value, you get the benefit of the Substitute, which replaces the "," with a ".".
Image

First of all thank you for help. When i saw your answer, i looked at about--> skin menu and i realized my fault. String is 7,8871 but Number is 7 and problem is here. How can i fix? What should i do for multiply with this string value?
I don't know where i going from here, but i promise it won't be boring... :great:
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Calculation formula for decimal number

Post by jsmorley »

tass_co wrote: December 11th, 2020, 1:10 pm Image

First of all thank you for help. When i saw your answer, i looked at about--> skin menu and i realized my fault. String is 7,8871 but Number is 7 and problem is here. How can i fix? What should i do for multiply with this string value?
As I said, simply add:

Substitute=",":"."

To the WebParser child measure that is returning that string.

Then use it in a formula with:

Code: Select all

[ClcCalc]
Measure=Calc
Formula=([MeasureTT] * 8970)
DynamicVariables=1

1.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
tass_co
Posts: 513
Joined: May 4th, 2020, 3:01 pm
Location: Ankara, TURKEY

Re: Calculation formula for decimal number

Post by tass_co »

jsmorley wrote: December 11th, 2020, 1:12 pm As I said, simply add:

Substitute=",":"."

To the WebParser child measure that is returning that string.

Then use it in a formula with:

Code: Select all

[ClcCalc]
Measure=Calc
Formula=([MeasureTT] * 8970)
DynamicVariables=1


1.jpg
It works. Thank you again :bow:
I don't know where i going from here, but i promise it won't be boring... :great:
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Calculation formula for decimal number

Post by jsmorley »

Glad to help.