Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negative numbers support? #135

Open
Lcchy opened this issue Dec 23, 2023 · 0 comments
Open

Negative numbers support? #135

Lcchy opened this issue Dec 23, 2023 · 0 comments

Comments

@Lcchy
Copy link

Lcchy commented Dec 23, 2023

Hi there, thanks a lot for this neat utility, I use it every day on my work computer.

In certain scripts I make use of negative numbers to indicate a further decrease in the output value. Wob indicates them in red which fits this use case nicely.

Nevertheless, it seems that negative numbers are somehow offset?
-1 displays a nearly empty bar and decreasing the input decreases the bar until -17 suddenly wraps around and displays a nearly full red bar (with -16 being an empty bar).
Decreasing the numbers further reduces the red bar intuitively but with and offset of 16.

I therefore wanted to ask, are negative numbers officially supported by wob? And if so, is this behavior known or might there be a bug hiding?

Thanks for the help.

EDIT:
I have just seen that input is assigned to an unsigned long:
(

wob/src/wob.c

Line 367 in 729e5c6

unsigned long percentage = strtoul(token, &str_end, 10);
)
So -1 just overflows and wraps around, wob handling it as (2^64 - 1) % 100 = 15
hence the offset I've observed.
For now I've just offset my script output as a workaround but I think it would be nice to have official negative numbers support, would you be open to it @francma ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant