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

NumberBox displays double 3.12 as 3.1999999999..... #9826

Open
Petrarca181 opened this issue Jul 17, 2024 · 4 comments
Open

NumberBox displays double 3.12 as 3.1999999999..... #9826

Petrarca181 opened this issue Jul 17, 2024 · 4 comments
Labels
area-NumberBox NumberBox Control bug Something isn't working team-Controls Issue for the Controls team

Comments

@Petrarca181
Copy link

Petrarca181 commented Jul 17, 2024

Describe the bug

As in title, any other number is ok only 3.12 is 3.199999999999...

image
image

Steps to reproduce the bug

Expected behavior

No response

Screenshots

No response

NuGet package version

None

Windows version

No response

Additional context

No response

@Petrarca181 Petrarca181 added the bug Something isn't working label Jul 17, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Jul 17, 2024
@DarranRowe
Copy link

I wonder if the actual value stored for 3.12 is far enough away from 3.12 that Xaml doesn't round it correctly. Well, floating point numbers are hard.

The actual value stored for 3.12 is:
float: 3.11999988555908203125
double: 3.12000000000000010658141036401502788066864013671875

These are the C/C++ types, but float is single precision (32 bit) and double is double precision (64 bit).

@Petrarca181
Copy link
Author

Petrarca181 commented Jul 17, 2024

I wonder if the actual value stored for 3.12 is far enough away from 3.12 that Xaml doesn't round it correctly. Well, floating point numbers are hard.

The actual value stored for 3.12 is: float: 3.11999988555908203125 double: 3.12000000000000010658141036401502788066864013671875

These are the C/C++ types, but float is single precision (32 bit) and double is double precision (64 bit).

NuberBox Value propertry is double. I can bind it to the ViewModel or asign value code behind, with same result.

@DarranRowe
Copy link

DarranRowe commented Jul 17, 2024

Then it is internally getting converted to float.

Just to clarify something important. There is a disagreement between the value in the original report. There is an image that states 3.1199999.... but the title states 3.199999.....
The image contains a value that would be understandable for a double->float conversion. The value in the title is completely unexpected. So I am making an assumption that the value in the title is a typo where the value in the image is the correct value.

@Balkoth
Copy link

Balkoth commented Jul 17, 2024

You could try to use decimal, but then you are even more effed, because you can not bind to decimal and need a converter.

@codendone codendone added area-NumberBox NumberBox Control team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-NumberBox NumberBox Control bug Something isn't working team-Controls Issue for the Controls team
Projects
None yet
Development

No branches or pull requests

4 participants