Uploaded image for project: 'Commons Validator'
  1. Commons Validator
  2. VALIDATOR-86

[validator] GenericTypeValidator does not accept negative Floats/Doubles

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Nightly Builds
    • None
    • None
    • None
    • Operating System: other
      Platform: Other

    • 36878

    Description

      There's a bug in the validation code of formatFloat:

      --snip--
      if (num.doubleValue() >= (Float.MIN_VALUE * -1) &&
      num.doubleValue() <= Float.MAX_VALUE)

      { result = new Float(num.floatValue()); }

      --snip--

      The lower border is checked against (Float.MIN_VALUE * -1). In contrast to
      Integer.MIN_VALUE, Float.MIN_VALUE does not represent the minimum value, but the
      smallest non-negative value. So the above check would crop all of the negative
      values.

      The same also applies to formatDouble.

      There's also an issue with the delimiter which is used to mark powers of 10^3:
      With Locale.US the following is accepted:

      2.5 This is ok
      2,500.0 This is ok
      2,5.0 This is transformed into 25.0

      Attachments

        Activity

          People

            Unassigned Unassigned
            newsscott@gmx.de Henning Moll
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: