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

NumericUpDown control #5318

Closed
dashenxian opened this issue Jan 19, 2021 · 5 comments · Fixed by #5981
Closed

NumericUpDown control #5318

dashenxian opened this issue Jan 19, 2021 · 5 comments · Fixed by #5981
Labels
bug help-wanted A contribution from the community would be most welcome.

Comments

@dashenxian
Copy link

Describe the bug
When the NumericUpDown control is at a value of 5.6 and Increment is 0.01, if adjusted up, it will appear as 0.570000000000000001 instead of 0.57

Code
<NumericUpDown Value="0.56" Minimum="0" Maximum="10" Increment="0.01"/>

Expected behavior
The value should beThe value should be 0.57

Screenshots
image
image

Desktop (please complete the following information):

  • OS: win 10
  • Version 0.9.12
@dashenxian
Copy link
Author

I know this is an error in floating-point calculations

@Takoooooo
Copy link
Contributor

Takoooooo commented Jan 19, 2021

value is double, should we consider making it decimal?
For example, in System.Windows.Forms, its done in the way suggested above
https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.numericupdown.value?view=net-5.0

@pr8x pr8x added the bug label Jan 19, 2021
@Takoooooo
Copy link
Contributor

I suggest adding up-for-grabs label because the solution to this issue seems pretty easy to me

@pr8x
Copy link
Contributor

pr8x commented Jan 20, 2021

I think we should port NumericUpDown.DecimalPlaces from WPF to correctly round the values: https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.numericupdown.decimalplaces?view=net-5.0

@pr8x pr8x added the help-wanted A contribution from the community would be most welcome. label Jan 20, 2021
@sn4k3
Copy link
Contributor

sn4k3 commented Jan 24, 2021

Related: #4756
To fix this i'm using FormatString="{}{0:0.00}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help-wanted A contribution from the community would be most welcome.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants