Results 1 to 3 of 3

Thread: [BUG:MAJOR, Beta3] - NumericFilter compares floating point numbers for equality

    Success! Looks like we've fixed this one. According to our records the fix was applied for EXTGWT-1453 in 3.0.
  1. #1
    Ext GWT Premium Member icfantv's Avatar
    Join Date
    Sep 2011
    Location
    Superior, CO
    Posts
    413
    Vote Rating
    21
      0  

    Exclamation [BUG:MAJOR, Beta3] - NumericFilter compares floating point numbers for equality

    Because of machine rounding (and as documented by Number.doubleValue) you cannot compare floating point numbers for equality using == or != without using some sort of epsilon/tolerance, i.e. abs(actual - expected) < epsilon.

    Here's the offending method (line 61):
    Code:
      protected boolean validateModel(M model) {
        Number val = getValueProvider().getValue(model);
        if (rangeMenu.eq != null && rangeMenu.eq.getCurrentValue() != null) {
          if (val == null || rangeMenu.eq.getCurrentValue().doubleValue() != val.doubleValue()) {
            return false;
          }
        }
    
        // ** snip **
      };

  2. #2
    Sencha User WesleyMoy's Avatar
    Join Date
    Oct 2009
    Location
    Redwood City, California
    Posts
    402
    Vote Rating
    2
      0  

    Default

    Thanks for bringing this to our attention. I've filed a ticket against the team to have a look.

  3. #3
    Ext GWT Premium Member icfantv's Avatar
    Join Date
    Sep 2011
    Location
    Superior, CO
    Posts
    413
    Vote Rating
    21
      0  

    Default

    You're welcome. I've been reading a bunch of stuff on the web for how to best go about solving this issue, if possible, in the GXT API.

    Per http://www.ibm.com/developerworks/ja...rary/j-jtp0114 (look at the section titled "BigDecimals for small numbers), it may make sense to use BigDecimal internally where appropriate, i.e., for floating point number types.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •