Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Slider % with decimals formatting issue

    Hi Isomporhic,

    I am having some trouble with the slider. It seems when I set the rangeFormat to a decimal format with a percent, the slider will occasionally display values with excessive decimal points. For example this slider is showing me 111.00000000001%, when I try to set it to 111.0%. It's also showing me 114.999999999999% instead of 115.0%. But other numbers are fine. It's just a few numbers that get displayed with the excessive decimal places. I played around with setRoundValues() and setRoundPrecision(), but it not seem to have an affect. Also it appears it only happens when the rangeFormat involves a %.



    Code:
            Slider slider = new Slider();
            slider.setMinValue(0);
            slider.setMaxValue(3.0);
            slider.setNumValues(300);
            slider.setRangeFormat("0.0#%");
            slider.setValueFormat("0.0#%");


    Thanks
    Last edited by pablo99; 18 Sep 2019, 10:08.

    #2
    This sample code wouldn't produce anything like you describe, since roundValues is true, so you could only ever get 100%, 200%, etc.

    Even with roundValues:false, we aren't seeing the problem you report.

    Best guess is that you've set roundPrecision to a large number like 10.

    Comment


      #3
      I updated my code and added a few more lines for completeness. I am testing with the most recent nightly build, SNAPSHOT_v12.1d_2019-09-19/LGPL Development Only. It appears to still occur whether the roundPrecision line is commented out or not. In this example I see it happening at 110.00000000001%, 220.0000000000003%, and 229.99999999997%.

      Code:
              HLayout fl = new HLayout();
              Slider zoomSlider = new Slider();
              zoomSlider.setMinValue(0.0);
              zoomSlider.setMaxValue(3.0);
              zoomSlider.setNumValues(300);
              zoomSlider.setRangeFormat("0.0#%");
              zoomSlider.setValueFormat("0.0#%");
              zoomSlider.setWidth(800);
              //zoomSlider.setRoundPrecision(2);
              zoomSlider.setRoundValues(false);
              zoomSlider.setVertical(false);
              zoomSlider.setTitle("Zoom");
              fl.addMember(zoomSlider);

      Comment


        #4
        That's how we tried it - both ways - and we did not reproduce the claimed problem.

        Let us know:
        1) which browsers this is reproducible on or not reproducible
        2) whether it is reproducible in development mode, or compiled mode, or just one. Also, which development mode you are using to test (SuperDevMode, legacy DevMode, etc)

        Comment


          #5
          I have replicated the issue on IE, FireFox, and Chrome. I am using compiled mode and have not tested on dev mode. Just to clarify, the issue is not readily apparent. It only affects a few numbers in the range so if I scroll slowly enough some numbers expand to a large width and can be detected.

          Comment


            #6
            We'll take a look and update here shortly

            Comment


              #7
              The precision issue was the result of a generic binary<->decimal conversion problem present in many languages - try evaluating 1.1*100 in your browser console to see what we mean.

              We've worked around it and you can try that change out in today's builds of 12.1, and tomorrow's builds for earlier branches..

              Comment


                #8
                The issue does indeed appear to be browser related, I tried the 1.1 * 100 evaluation in the browser and see the extra decimals. However I pulled down the newest nightly build jar to test the workaround but am still sporadically seeing the same precision issue on various notches of the slider. So the workaround may not be catching all the cases? I included my code below. Thanks for the help on this.


                Code:
                slider.setMinValue(0);
                slider.setMaxValue(1.0);
                slider.setRoundPrecision(3);
                slider.setRangeFormat("0.0#%");
                slider.setValueFormat("0.0#%");
                slider.setRoundValues(false);
                slider.setVertical(false);
                slider.setNumValues(201);

                Comment


                  #9
                  We've worked around this too - but can you clarify what it is you're trying to do here?

                  This sample is different from your last one - specifically, this one specifies decimalPrecision of 3, and max value 1 - and, for some reason, 201 stops...

                  Are you trying to provide and retrieve a value less than one, to three decimal places (which fraction will never happen because your numValues means you'll never go to more than 2), but display soemthing like "100.000%"?

                  Comment


                    #10
                    In fact, we've fixed what appears to be the underlying problem here - please retest with a build dated October 1 or later.

                    Comment

                    Working...
                    X