Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-04-28 Thread Pankaj Bansal
9:46 PM To: Pankaj Bansal ; Volodin, Vladislav Cc: swing-dev@openjdk.java.net; Jason Mehrens ; Alexey Ivanov Subject: Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue Probably I missed the point but isn't it too many changes for this? Number base, expectedNe

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-04-16 Thread Sergey Bylokhov
xed separately. Regards, Pankaj -Original Message- From: Sergey Bylokhov Sent: Tuesday, April 7, 2020 9:46 PM To: Pankaj Bansal ; Volodin, Vladislav Cc: swing-dev@openjdk.java.net; Jason Mehrens ; Alexey Ivanov Subject: Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding i

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-04-07 Thread Pankaj Bansal
<< Probably I missed the point but isn't it too many changes for this? <; Volodin, Vladislav Cc: swing-dev@openjdk.java.net; Jason Mehrens ; Alexey Ivanov Subject: Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue Probably I missed the point but isn

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-04-07 Thread Sergey Bylokhov
sal/8220811/webrev02/ Regards, Pankaj -Original Message- From: Volodin, Vladislav Sent: Sunday, March 15, 2020 2:03 AM To: Pankaj Bansal Cc: swing-dev@openjdk.java.net; Jason Mehrens ; Sergey Bylokhov ; Alexey Ivanov Subject: Re: [15] RFR JDK-8220811: SpinnerNumberModel floating

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-04-07 Thread Pankaj Bansal
ansal/8220811/webrev02/ Regards, Pankaj -Original Message- From: Volodin, Vladislav Sent: Sunday, March 15, 2020 2:03 AM To: Pankaj Bansal Cc: swing-dev@openjdk.java.net; Jason Mehrens ; Sergey Bylokhov ; Alexey Ivanov Subject: Re: [15] RFR JDK-8220811: SpinnerNumberModel floating po

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-03-14 Thread Volodin, Vladislav
egards, Pankaj -Original Message- From: Jason Mehrens Sent: Saturday, March 14, 2020 8:09 PM To: Pankaj Bansal ; Sergey Bylokhov ; Alexey Ivanov ; Volodin, Vladislav Cc: swing-dev@openjdk.java.net Subject: Re: [15] RFR JDK-8220811: SpinnerNumberMod

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-03-14 Thread Pankaj Bansal
Bansal Sent: Saturday, March 14, 2020 8:11 AM To: Sergey Bylokhov; Alexey Ivanov; Volodin, Vladislav Cc: swing-dev@openjdk.java.net Subject: Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue Hello Sergey, << It will differ for two cases: - The error will not be

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-03-14 Thread Jason Mehrens
, March 14, 2020 8:11 AM To: Sergey Bylokhov; Alexey Ivanov; Volodin, Vladislav Cc: swing-dev@openjdk.java.net Subject: Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue Hello Sergey, << It will differ for two cases: - The error will not be accumulated when the c

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-03-14 Thread Pankaj Bansal
lokhov Sent: Wednesday, March 11, 2020 5:33 AM To: Pankaj Bansal ; Alexey Ivanov ; Volodin, Vladislav Cc: swing-dev@openjdk.java.net Subject: Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue On 3/10/20 5:34 am, Pankaj Bansal wrote: > Hello Sergey/Vlad/Alexey, >

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-03-10 Thread Sergey Bylokhov
On 3/10/20 5:34 am, Pankaj Bansal wrote: Hello Sergey/Vlad/Alexey, Sorry, I could not reply to this earlier. I have one doubt about this approach. Won't the calculation of stepCount itself suffer from floating point issue? I mean the user will pass min, max, stepsize, then wont the calculation

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-03-10 Thread Pankaj Bansal
Hello Sergey/Vlad/Alexey, Sorry, I could not reply to this earlier. I have one doubt about this approach. Won't the calculation of stepCount itself suffer from floating point issue? I mean the user will pass min, max, stepsize, then wont the calculation of steps required to go from min to max

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-02-18 Thread Sergey Bylokhov
I think it should work, the step will counts from the default value. So currently: 1. if the user set default value to X1 and then he iterates forward 100 times then he will get some X2. During this calculation, he could get "100" rounding issues. 2. If later the user decides iterates backward t

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-02-17 Thread Alexey Ivanov
On 17/02/2020 10:35, Sergey Bylokhov wrote: On 2/17/20 2:25 am, Alexey Ivanov wrote: As far as I understand your approach, is to select the minimum if the resulted float value after the calculation is a little bit smaller than the minimum. So if the minimum is -0.15 and resulted value is (-0.

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-02-17 Thread Sergey Bylokhov
On 2/17/20 2:25 am, Alexey Ivanov wrote: As far as I understand your approach, is to select the minimum if the resulted float value after the calculation is a little bit smaller than the minimum. So if the minimum is -0.15 and resulted value is (-0.10d - 0.05d) = (-0.15002), what v

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-02-17 Thread Alexey Ivanov
On 17/02/2020 10:10, Sergey Bylokhov wrote: On 2/17/20 1:50 am, Alexey Ivanov wrote: Otherwise there will always be cases where Spinner with float/double behaves unexpectedly, i.e. does not allow increasing/decreasing a value where one expects it to. But what value is expected/unexpected? If

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-02-17 Thread Sergey Bylokhov
On 2/17/20 1:50 am, Alexey Ivanov wrote: Otherwise there will always be cases where Spinner with float/double behaves unexpectedly, i.e. does not allow increasing/decreasing a value where one expects it to. But what value is expected/unexpected? If the programmer wants to use float arithmeti

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-02-17 Thread Alexey Ivanov
Hi Vlad, The idea looks reasonable. However, it does not allow for manual editing. The cases where max and min values are not multiples of step would be hard to handle with this approach. For example: max = 10.05, min = 0.01, step = 0.1; how many ticks are there? What if the user enters 1.010

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-02-17 Thread Alexey Ivanov
On 13/02/2020 21:33, Sergey Bylokhov wrote: On 2/12/20 8:21 am, Alexey Ivanov wrote: The bug report says that going from -0.15 to -0.10 does not allow going back to -0.15. This happens because the result of this sequence of operations cannot be represented exactly, or, in other words, because

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-02-13 Thread Volodin, Vladislav
Hello Sergey, Alexey and Pankaj, I am reading the current discussion and I was thinking about an idea changing the code in the way that instead of working with float/double numbers we work with integer ticks. For example, the model remembers the min/max/step values and calculates a number of st

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-02-13 Thread Sergey Bylokhov
On 2/12/20 8:21 am, Alexey Ivanov wrote: The bug report says that going from -0.15 to -0.10 does not allow going back to -0.15. This happens because the result of this sequence of operations cannot be represented exactly, or, in other words, because of rounding errors; or rather the result is

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-02-12 Thread Alexey Ivanov
Subject: Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue I am not able to find any issue with this approach. Sometimes there are difference: double b = 0.10011; constructor [1]: 0.1001165734175856414367444813251495361328125 con

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-02-12 Thread Sergey Bylokhov
essage- From: Sergey Bylokhov Sent: Wednesday, February 12, 2020 1:09 PM To: Pankaj Bansal ; swing-dev@openjdk.java.net Subject: Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue I am not able to find any issue with this approach. Sometimes there are difference: do

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-02-11 Thread Pankaj Bansal
a+b*c. Regards, Pankaj -Original Message- From: Sergey Bylokhov Sent: Wednesday, February 12, 2020 1:09 PM To: Pankaj Bansal ; swing-dev@openjdk.java.net Subject: Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue > I am not able to find any issue with this

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-02-11 Thread Sergey Bylokhov
I am not able to find any issue with this approach. Sometimes there are difference: double b = 0.10011; constructor [1]: 0.1001165734175856414367444813251495361328125 constructor [2]: 0.10012 < minimum, Comparable maximum,

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-02-11 Thread Pankaj Bansal
February 12, 2020 2:17 AM To: Pankaj Bansal ; swing-dev@openjdk.java.net Subject: Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue On 2/11/20 3:40 am, Pankaj Bansal wrote: > << Could you please try to use Math.fma instead of direct using of > xxx.toString

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-02-11 Thread Sergey Bylokhov
On 2/11/20 3:40 am, Pankaj Bansal wrote: << Could you please try to use Math.fma instead of direct using of xxx.toString+BigDecimal I tried using this, but Math.fma will not solve our issue of precision here. Math.fma internally creates BigDecimal, but it uses the [1] type constructor to creat

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-02-11 Thread Pankaj Bansal
nt value, int minimum, int maximum, int stepSize) Regards, Pankaj -Original Message- From: Sergey Bylokhov Sent: Tuesday, February 11, 2020 7:47 AM To: Pankaj Bansal ; swing-dev@openjdk.java.net Subject: Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue Hi, Pan

Re: [15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-02-10 Thread Sergey Bylokhov
Hi, Pankaj. Could you please try to use Math.fma instead of direct using of xxx.toString+BigDecimal if (value instanceof Double) { newValue = Math.fma(stepSize.doubleValue(), dir, value.doubleValue()); } else { newValue = Math.fma(stepSize.floatValue(), dir, value.floatValue()); } Ar

[15] RFR JDK-8220811: SpinnerNumberModel floating point rounding issue

2020-02-07 Thread Pankaj Bansal
Hi All, Please review the following fix for jdk15. Bug: https://bugs.openjdk.java.net/browse/JDK-8220811 webrev: http://cr.openjdk.java.net/~pbansal/8220811/webrev00/ Issue: In case of JSpinner with double/float values, sometime the spinner value does not change even though the val