Talk:Determine if a string is numeric: Difference between revisions

In a previous life
(→‎Exact definition of IsNumeric?: What the language would recognise.)
(In a previous life)
Line 89:
--[[User:Markhobley|Markhobley]] 16:28, 4 June 2011 (UTC)
:Whatever would be a legal numeric literal accepted by the language compiler/interpreter - thus making it language specific? --[[User:Paddy3118|Paddy3118]] 20:10, 4 June 2011 (UTC)
::I'm not sure. In theory, the application program could support the various numeric formats, even though the underlying language may not. --[[User:Markhobley|Markhobley]] 21:38, 4 June 2011 (UTC)
 
I think we can say that expressions and the invalid numbers are not numeric strings, but this then means we need sufficient logic in the code to be able to identify these as such.
 
In the past, I have assumed that the number system was decimal and accepted only digits, an optional leading hyphen, and a single decimal point. With that logic, "a numeric string is a string consisting only of digits, an optional leading hyphen and an optional single decimal point". Maybe this is the way to go. Note that in some locales, numeric strings fall outside of this definition, so this also needs to be considered. Under that definition strings containing whitespace return a result of "not numeric", but this does not matter in practice, because code that makes use of the result can easily trim whitespace from the string before feeding it to the evaluator (I have done this before and it has worked well for me). --[[User:Markhobley|Markhobley]] 21:38, 4 June 2011 (UTC)
 
== Objective-C question ==