Currently there is a problem with the Stepper, when the increment is smaller than 0.5.
The rounding are totaly wrong per increment. On some increment the initial 0 value is wrong.
The problem exisits only, when the Value is between -1 and +1
Values larger than 1 or smaller than -1 are correct.
increment: 0.06 => 0.0, 0.06, 0.12, 0.18, ....
increment: 0.05 => 0, 0.05, 0.10, 0.15, ....
increment: 0.06 => 0.0199999999999996, 0.0800000000000001, 0.139999999999999, 0.199999999999999, ....
increment: 0.05 => 0, 0.0500000000000007, 0.100000000000001, 0.15, ....
No workaround
could you please attach a repro project ? thanks
I created a small sample project with this issue.
Stepper Issues.zip
There i figured out that the issue is depending on large Minimum and Maximum values.
There is also one more problem:
Setting a large minimum value (int.MinValue or double.MinValue) is not possible.
The smallest Minvalue allowed is -2147483637.
The Minimum value is of type double so double.MinValue should be possible.
A simplified version of the above sample project:
Stepper Issues (simplyfied).zip
The initial value being wrong is a real concern. The rounding is most likely a case of a floating point value converted to decimal, and not considered as a bug, but I'm checking this as well.
this is likely related to (or was regressed by) #7383
see also #10032
Hi there @lathan86 I worked on one of the PR's (#7383) and it was to fox an issue where the result of using small numbers gave a double result with a very small floating point error so 0.05 would be 0.0500000001. This stems from the use of Doubles in the calculations rather than Decimals, but changing type was not possible as it would be a breaking change.
In fixing this I added after much playing around a Step Counter that holds an Int of the current stepper position between Stepper.Min and Stepper.Max and I think it's this that is causing the issue you raise. Looking at your sample Repo you have a Min of -100000 and Max of 100000 so a very small step like you have pointed out may cause this to fall over. In the Tests I amended I did make sure I tested with small values I think one is 0.25 and that worked BUT the Min was always 0... None of the tests had a negative number in them for the Min and in the project I was working on at the time it wasn't needed either. Basically I didn't think of this use case and sadly messed it up sorry.
As for the comment on the smallest min value this comes from the same line of code where the StepCounter I used was an Int so that will cause the issue.
@StephaneDelcroix Happy to take another swing at this to see if I can fix my error, and maybe this time add a test case with some larger Min/Max and smaller Increments just to be sure it works.
@CliffAgius I'm on it. the problem with step counter is when you change the increment. I'm trying a different approach
I think if there was scope to make the change to using a decimal rather than a Double for all the values like that of the Slider all these issues go away. But it would be a breaking change so maybe add this to the List of things for MAUI of V5.0 of XF rather than hack it out here.
I think if there was scope to make the change to using a decimal rather than a Double for all the values like that of the Slider all these issues go away. But it would be a breaking change so maybe add this to the List of things for MAUI of V5.0 of XF rather than hack it out here.
i think also decimal will be a better option than double, because the rounding precision will be better.