It is currently April 18th, 2024, 3:18 pm

Decimals in Log

Get help with creating, editing & fixing problems with skins
User avatar
Yincognito
Rainmeter Sage
Posts: 7120
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Decimals in Log

Post by Yincognito »

I'm working on a skin that I will post it in Tips and Tricks section and I need to work with a larger number of decimals (not related to the NumOfDecimals option in the String meter). So far, both in the log and in my numerical/string meter output, I'm only able to see (thus, work with) a maximum of 5 decimals. Why is that and is there a limit on how many decimals Rainmeter works with when talking about numerical values? Can something be done to increase that limit?

Code: Select all

[MS_X]
Measure=Calc
Formula=(1/(10**6))
;Formula=0.000001
DynamicVariables=1
The measure above outputs 0, and not 0.000001, both in the log and in a meter.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16143
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Decimals in Log

Post by balala »

It seems there indeed the number of decimals is limited to 5 in log. But not in String meters. In string meters this limit is around 125! Up to 125 decimals are allowed (using the appropriate NumOfDecimals option):

Code: Select all

[Rainmeter]
Update=-1

[MeasureNum]
Measure=Calc
Formula=( MeasureNum + 1 )

[MS_X]
Measure=Calc
Formula=(1/(10**[MeasureNum]))
;Formula=0.000001
DynamicVariables=1

[MeterOpenStart]
Meter=STRING
MeasureName=MS_X
MeasureName2=MeasureNum
X=0
Y=0
Padding=15,5,15,5
FontColor=220,220,220
SolidColor=0,0,0,150
FontSize=12
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=%2#CRLF#%1
NumOfDecimals=[MeasureNum]
DynamicVariables=1
LeftMouseUpAction=[!UpdateMeasure "MeasureNum"][!UpdateMEasure "MS_X"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
Have no idea why exactly 125, though.
User avatar
Yincognito
Rainmeter Sage
Posts: 7120
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Decimals in Log

Post by Yincognito »

balala wrote: December 22nd, 2018, 5:25 pm It seems there indeed the number of decimals is limited to 5 in log. But not in String meters. In string meters this limit is around 125! Up to 125 decimals are allowed (using the appropriate NumOfDecimals option). Have no idea why exactly 125, though.
Well, it doesn't help how many decimals you can have in a string meter anyway, since a string meter of a number uses the number itself as a base. So, when Rainmeter is turning the number 0.000001 into 0, you can have, say 6 decimals in the string meter all you like, that string would still be 0.000000 instead of 0.000001 - correct me if I'm wrong... :confused:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16143
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Decimals in Log

Post by balala »

Yincognito wrote: December 22nd, 2018, 6:26 pm Well, it doesn't help how many decimals you can have in a string meter anyway, since a string meter of a number uses the number itself as a base. So, when Rainmeter is turning the number 0.000001 into 0, you can have, say 6 decimals in the string meter all you like, that string would still be 0.000000 instead of 0.000001 - correct me if I'm wrong... :confused:
I think you are. If you set the NumOfDecimals option on the String meter to 6, you'll get 0.000001, not 0.000000. However if there is no NumOfDecimals option on the String meter, the default NumOfDecimals=0 is used, rounding the number to the nearest integer.
Please post a code sample, to can see where the problem resides.
User avatar
Yincognito
Rainmeter Sage
Posts: 7120
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Decimals in Log

Post by Yincognito »

balala wrote: December 22nd, 2018, 6:38 pmPlease post a code sample, to can see where the problem resides.
I don't want to post the actual code yet, as it is intended to be posted in Tips & Tricks section once it works as expected. I can replicate the behavior based on your example though:

Code: Select all

[Rainmeter]
Update=-1

[MeasureNum]
Measure=Calc
Formula=( MeasureNum + 1 )

[MS_X]
Measure=Calc
Formula=(1/(10**[MeasureNum]))
;Formula=0.000001
DynamicVariables=1

[MS_Y]
Measure=String
String=[MS_X:],[MS_X]
RegExpSubstitute=1
Substitute="^(.*)$":"Value is eventually lost: \1"
DynamicVariables=1

[MeterOpenStart]
Meter=STRING
MeasureName=MS_X
MeasureName2=MeasureNum
MeasureName3=MS_Y
X=0
Y=0
Padding=15,5,15,5
FontColor=220,220,220
SolidColor=0,0,0,150
FontSize=12
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=%2#CRLF#%1#CRLF#%3
NumOfDecimals=[MeasureNum]
DynamicVariables=1
LeftMouseUpAction=[!UpdateMeasure "MeasureNum"][!UpdateMEasure "MS_X"][!UpdateMeasure "MS_Y"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
I think the issue happens in my code because I intentionally use a lower NumOfDecimals (actually a [Measure:NumOfDecimals]) than the number of decimals I work with in the measure itself. I do this because I need the meter to "hide" the decimals I work with in the measure, since they're only used as an "ID" for a regex substitute.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16143
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Decimals in Log

Post by balala »

It seems a String meter shows the numeric value with the set number of decimals ONLY if it is set through a MeasureName option. If you set it through a Text=[MS_X] option, just up to six decimals can be shown.
:o Interesting. Didn't know about this limitation. :o
Good to be known, however.
User avatar
Yincognito
Rainmeter Sage
Posts: 7120
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Decimals in Log

Post by Yincognito »

balala wrote: December 22nd, 2018, 8:11 pm It seems a String meter shows the numeric value with the set number of decimals ONLY if it is set through a MeasureName option. If you set it through a Text=[MS_X] option, just up to six decimals can be shown.
:o Interesting. Didn't know about this limitation. :o
Good to be known, however.
Yep, that's what I was talking about ... sort of. I use the [MS_X] style for demonstration purposes in my skin, to display both the number and the string value of my result. It makes sense, in my case, since the result must be available in tooltips, where the MeasureName option is limited to, among others, NumOfDecimals=0, according to the manual.

For the record, I'm working on AutoScale / Scale in tooltips. I used the code for years with no issues, but now I thought about sharing it with the community. What I want to achieve - and why I needed to tweak my already working code, instead of simply posting it as it was - is to make the skin use close to 0 hardcoded values, playing only with a few variables.

Anyway, I now use a workaround for the decimals issue in the measure, but I'm still limited by the 5 max decimals (4 in my case, since the 5th is used in the regex substitute), as it breaks the whole output if I set my #Decimals# variable to 5 or higher...
Last edited by Yincognito on December 22nd, 2018, 8:45 pm, edited 1 time in total.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16143
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Decimals in Log

Post by balala »

Yincognito wrote: December 22nd, 2018, 8:36 pm Yep, that's what I was talking about ... sort of. I use the [MS_X] style for demonstration purposes in my skin, to display both the number and the string value of my result. It makes sense, in my case, since the result must be available in tooltips, where the MeasureName option is limited to, among others, NumOfDecimals=0, according to the manual.

For the record, I'm working on AutoScale / Scale in tooltips. I used the code for years with no issues, but now I thought about sharing it with the community. What I want to achieve - and why I needed to tweak my already working code, instead of simply posting it as it was - is to make the skin use close to 0 hardcoded values, playing only with a few variables.

Anyway, I now use a workaround for the decimals issue in the measure, but I'm still limited by the 5 max decimals if I set the scale to higher values...
No more comments, from my part, just that I didn't know about this limitation.
rxtd
Posts: 100
Joined: April 30th, 2017, 11:51 am

Re: Decimals in Log

Post by rxtd »

balala wrote: December 22nd, 2018, 8:11 pm It seems a String meter shows the numeric value with the set number of decimals ONLY if it is set through a MeasureName option. If you set it through a Text=[MS_X] option, just up to six decimals can be shown.
:o Interesting. Didn't know about this limitation. :o
Good to be known, however.
Yincognito wrote: December 22nd, 2018, 8:36 pm Anyway, I now use a workaround for the decimals issue in the measure, but I'm still limited by the 5 max decimals (4 in my case, since the 5th is used in the regex substitute), as it breaks the whole output if I set my #Decimals# variable to 5 or higher...
[SomeMeasure] is not some magic value, it's a Section variable which is string, and strings don't have any precision.
It has nothing to do with String meter—string values behave the same way everywhere.

There is kind of a coincidence that string values of some measures match their number values. Or, to be exact, some measures (maybe all built-in measures, I didn't check) don't have any string value, so Rainmeter transforms their number values into string.
You can control how Rainmeter does that using parameters in section variables. You can read about it in the Section variables' page.

For example, if you need some known precision, you can use ":n": [SomeMeasure:7] will give you string, containing number with 7 decimal places. [SomeMeasure:] will give you string containing number with up to 10 decimal places.
User avatar
balala
Rainmeter Sage
Posts: 16143
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Decimals in Log

Post by balala »

rxtd wrote: December 23rd, 2018, 8:23 am [SomeMeasure] is not some magic value, it's a Section variable
Have I said it's something magic?
Asking just rhetorically... :Whistle