commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benedikt Ritter (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (LANG-1016) NumberUtils#isParseable method(s)
Date Mon, 07 Jul 2014 18:02:34 GMT

    [ https://issues.apache.org/jira/browse/LANG-1016?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14048107#comment-14048107
] 

Benedikt Ritter edited comment on LANG-1016 at 7/7/14 6:01 PM:
---------------------------------------------------------------

Hi again,

I'm fine with {{isParseable}}. One thing I'm not sure about is, whether we should only provide
one method. If you get a String from somewhere and isParsebale returns true, you don't know
if the string can be parsed as an integer or if you have to parse it to double. Maybe we need
one method for each number type?

bq. Regarding the 64L issue, Long.parseLong( "64L" ) yields a NumberFormatException, while
the javadocs from Long#parseLong() state:

d'oh, that's a bit embarrassing. Sorry for the non sense :o) 


was (Author: britter):
Hi again,

I'm fine with {{isParseable}}. One thing I'm not sure about is, whether we should only provide
one method. If you get a String from somewhere and isParsebale returns true, you don't know
if the string can be parsed as an integer or if you have to parse it to double. Maybe we need
one method for each number type?

bg. Regarding the 64L issue, Long.parseLong( "64L" ) yields a NumberFormatException, while
the javadocs from Long#parseLong() state:

d'oh, that's a bit embarrassing. Sorry for the non sense :o) 

> NumberUtils#isParseable method(s)
> ---------------------------------
>
>                 Key: LANG-1016
>                 URL: https://issues.apache.org/jira/browse/LANG-1016
>             Project: Commons Lang
>          Issue Type: Wish
>          Components: lang.math.*
>            Reporter: Juan Pablo Santos Rodríguez
>             Fix For: Review Patch, Discussion
>
>
> (for background see [LANG-997|https://issues.apache.org/jira/browse/LANG-997?focusedCommentId=13991193&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13991193])
> It would be nice to have an {{isParseable}} method (or whatever it may be called), to
be able to identify valid (=parseable) Numbers, something along the lines {{toDouble(String)}}
/ {{toLong(String)}} etc., but returning {{true}} / {{false}} while avoiding at the same time
the {{try/catch(NumberFormatException)}} of those methods.
> This method would be similar to {{isNumber}}, but it should yield {{true}} for invalid
octals like "018" which are parseable as Numbers. The point of this method is to identify
"human" (neither hex nor octal, but should handle decimal points) numbers stored as Strings,

> We are using NumberUtils#isNumber to identify valid (parseable, human) numbers, but as
of 3.3, this method also handles octal numbers, so, f.ex.,  018, which was recognized as a
valid number, isn't recognized anymore as one.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message