It is currently December 15th, 2019, 6:21 am

Rainmeter "Round" returning "-0" for values between 0 and -0.3

Help with creating, editing & fixing problems with skins
AttemptsAtFlight
Posts: 4
Joined: October 2nd, 2019, 4:18 pm

Rainmeter "Round" returning "-0" for values between 0 and -0.3

AttemptsAtFlight » November 3rd, 2019, 6:43 am

So it's starting to get cold here and I'm noticing this for the first time, I think the title sums it up pretty well, I'm using the Round formula to get decimal point temperatures to be a single digit but for the specific values that are in the negatives, but aren't large enough to round to -1, it seems like Rainmeter returns me a "-0" result. My code is below, do I appear to be doing something wrong? And if not, how do I get it to display 0 instead?

Code: Select all

[MeasureFeelsLike]
Measure=Plugin
Plugin=WebParser
Url=[mWeatherData]
StringIndex=9

[mFeelsLike]
Measure=Calc
Formula=Round([MeasureFeelsLike],0)
DynamicVariables=1
And here's an example input/output

https://i.gyazo.com/a77737bb1a4892cfffe4ddd8d631d8bf.png
User avatar
balala
Rainmeter Sage
Posts: 9267
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Rainmeter "Round" returning "-0" for values between 0 and -0.3

balala » November 3rd, 2019, 7:25 am

AttemptsAtFlight wrote:
November 3rd, 2019, 6:43 am
And if not, how do I get it to display 0 instead?
Try the following formula into the [mFeelsLike] measure: Formula=(( Round ( [MeasureFeelsLike], 0 ) = 0 ) ? 0 : Round ( [MeasureFeelsLike], 0 )).
mak_kawa
Posts: 371
Joined: December 30th, 2015, 9:47 am

Re: Rainmeter "Round" returning "-0" for values between 0 and -0.3

mak_kawa » November 3rd, 2019, 7:51 am

balala's solution is really smart, I think. My simple suggestion is... how about adding Substitute="-0":"0" to the measure [mFeelsLike]?
User avatar
balala
Rainmeter Sage
Posts: 9267
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Rainmeter "Round" returning "-0" for values between 0 and -0.3

balala » November 3rd, 2019, 9:29 am

mak_kawa wrote:
November 3rd, 2019, 7:51 am
My simple suggestion is... how about adding Substitute="-0":"0" to the measure [mFeelsLike]?
Right, another good solution. But note that this has to be added to the original [mFeelsLike] measure, not to the modified one (not to that using my updated formula).
AttemptsAtFlight
Posts: 4
Joined: October 2nd, 2019, 4:18 pm

Re: Rainmeter "Round" returning "-0" for values between 0 and -0.3

AttemptsAtFlight » November 4th, 2019, 3:30 am

Respectively super clever and super simple, thank you both :)
User avatar
balala
Rainmeter Sage
Posts: 9267
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Rainmeter "Round" returning "-0" for values between 0 and -0.3

balala » November 4th, 2019, 3:04 pm

AttemptsAtFlight wrote:
November 4th, 2019, 3:30 am
Respectively super clever and super simple, thank you both :)
I'm glad from my part if I helped.