commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject cvs commit: jakarta-commons-sandbox/lang/src/java/org/apache/commons/lang Numbers.java
Date Sun, 14 Jul 2002 05:15:03 GMT
bayard      2002/07/13 22:15:03

  Modified:    lang/src/java/org/apache/commons/lang Numbers.java
  Log:
  Added a check for -- at the start of a number to createNumber.
  BigDecimal(String) appears to parse this without it being mentioned in
  the spec/javadoc. On Apple's OS X it parses to the wrong value so I
  suspect it is untrustworthy.
  
  Revision  Changes    Path
  1.7       +8 -1      jakarta-commons-sandbox/lang/src/java/org/apache/commons/lang/Numbers.java
  
  Index: Numbers.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/lang/src/java/org/apache/commons/lang/Numbers.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Numbers.java	8 Jul 2002 22:06:50 -0000	1.6
  +++ Numbers.java	14 Jul 2002 05:15:03 -0000	1.7
  @@ -157,6 +157,13 @@
           if (val.length() == 0) {
               throw new NumberFormatException("\"\" is not a valid number.");
           }
  +        if (val.startsWith("--")) {
  +            // this is protection for poorness in java.lang.BigDecimal.
  +            // it accepts this as a legal value, but it does not appear 
  +            // to be in specification of class. OS X Java parses it to 
  +            // a wrong value.
  +            return null;
  +        }
           if (val.startsWith("0x") || val.startsWith("-0x")) {
               return createInteger(val);
           }   
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message