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

Making number steppers working with decimal numbers #561

Merged
merged 4 commits into from
Jan 8, 2024

Conversation

Shallowmallow
Copy link
Contributor

<vbox>
    <number-stepper pos="5" step="1" />
    <number-stepper pos="5" step="0.1" /> 
    <number-stepper pos="5" step="0.01" />   
</vbox>

When incrementing step, it would add 0,999999999
And didn't validate values correctly.

It isn't perfect, seems roundToNearest doesn't always work ( with a step of 0.13 for example)

@Shallowmallow
Copy link
Contributor Author

I have a better roundToNearest now, but I see some probs with my fmodulo, now. So I'll have a think. Damn floats.

@Shallowmallow
Copy link
Contributor Author

OKay I'm satisfied with it. I put some kind of arbitrary number (5) to limit the precision. if a float is too precise, when multiplied and converted to int it causes problems ( I mean when 0.0006 is converted to 6). I don't know how to call it so didn't static inline it ( yes bad) .
I think it was the best limit I found, but maybe there is a way to calculate it ?

@Shallowmallow
Copy link
Contributor Author

Better explanations, you can test improved roundToNearest with for example : haxe.ui.util.MathUtil.roundToNearest(8.190000000000001, 0.13)

@ianharrigan ianharrigan merged commit dd0fd80 into haxeui:master Jan 8, 2024
1 check passed
@ianharrigan
Copy link
Member

thanks!

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

Successfully merging this pull request may close these issues.

2 participants