commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rand McNeely" <rand_mcne...@yahoo.com>
Subject RE: [lang] patch NumbersTest.java
Date Wed, 03 Jul 2002 00:06:12 GMT
Here's the fix.  I had to completely rewrite the method.  I've attached
the patch for Numbers.java, build.xml and I've attached
NumbersTest.java.

Here's the new logic for createNumber(String val)..

If it has a type qualifier on the end (l, d, f, etc), start with the 
Specified class and work your way up until you find one that will hold
it.

Otherwise, start from Float/Integer and keep trying all the way until
BigDecimal/BigInteger.  

All else fails, try hex.

> -----Original Message-----
> From: Stephen Colebourne [mailto:scolebourne@btopenworld.com]
> Sent: Tuesday, July 02, 2002 2:26 PM
> To: Jakarta Commons Developers List
> Subject: Re: [lang] NumbersTest.java
> 
> Yes, it looks like the intention of the code is to return the correct
> type,
> and thus it should treat the letters f, d, l as more important than
> trusting
> the java methods. Both cases should be handled. Both should drop back
to
> BigDeciomal/BigInteger as appropriate.
> 
> Can you fix the class, expanding on the javadoc to explain how it
works?
> I'd
> rather hold off on the test just until it runs without errors ;-)
> 
> Stephen
> 
> ----- Original Message -----
> From: "Rand McNeely" <rand_mcneely@yahoo.com>
> To: "'Jakarta Commons Developers List'"
<commons-dev@jakarta.apache.org>
> Sent: Tuesday, July 02, 2002 4:16 AM
> Subject: [lang] NumbersTest.java
> 
> 
> >
> >
> > One of the tests is actually failing (createNumber(String) 3) on JDK
> > 1.4.  If I am understanding the intentions of createNumber, it
should
> > return a Double when passed "1234.5D" but it is returning a Float.
It
> > looks like Float.valueOf(String) is not throwing a
NumberFormatException
> > for "1234.5D" as you would expect (Long.valueOf(String) will throw
an
> > exception for "12345L") - a small inconsistency in the JDK.
> >
> > Should we modify the logic to first check for F's or D's before the
> > indiscriminately calling createFloat and createDouble?
> >
> > Rand
> >
> >
> >
> 
> 
>
------------------------------------------------------------------------
--
> --
> ----
> 
> 
> > --
> > To unsubscribe, e-mail:
> <mailto:commons-dev-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> <mailto:commons-dev-help@jakarta.apache.org>
> 
> 
> --
> 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