Talk:Determine if a string is numeric: Difference between revisions
Content added Content deleted
(we need clarification of what is classed as a numeric string) |
|||
Line 60: | Line 60: | ||
:: I hadn't realized that there was an ambiguity. I hadn't even realized that "isnumeric" is a VB function (I certainly don'ty know VB). In the two examples I contributed (IDL and TCL) I assumed that the task meant that something would be interpreted as a number if handed to the language in question. I.e. if I can multiply it with two or take the sin() of it then it is numeric. For example in IDL I might say "sin(double(x))" where "double(x)" converts the input into a "double" (8-byte float) which will fail if "x" is, for example, the string "foo". I trap the error and decide what is or isn't "numeric" based on the occurrence of this kind of error. This will allow "1.1" or "-.1e-04" or "+000003" etc. |
:: I hadn't realized that there was an ambiguity. I hadn't even realized that "isnumeric" is a VB function (I certainly don'ty know VB). In the two examples I contributed (IDL and TCL) I assumed that the task meant that something would be interpreted as a number if handed to the language in question. I.e. if I can multiply it with two or take the sin() of it then it is numeric. For example in IDL I might say "sin(double(x))" where "double(x)" converts the input into a "double" (8-byte float) which will fail if "x" is, for example, the string "foo". I trap the error and decide what is or isn't "numeric" based on the occurrence of this kind of error. This will allow "1.1" or "-.1e-04" or "+000003" etc. |
||
:: Should we tag the task for clarification? [[User:Sgeier|Sgeier]] 10:34, 20 September 2007 (MDT) |
:: Should we tag the task for clarification? [[User:Sgeier|Sgeier]] 10:34, 20 September 2007 (MDT) |
||
:::I think we need clarification of what is classed as a numeric string. Are commas allowed in the string? Must they be in certain places? What about strings containing numbers represented using underscore annotation? Or numbers in a notation that represents a non-decimal base? |
|||
Which of the following example strings are classed as numeric for the purpose of this task? |
|||
* "20,376" |
|||
* "20367" |
|||
* "20 368" |
|||
* "203 69" |
|||
* "20_367" |
|||
* "203_76" |
|||
* "0x1234" - Hexadecimal |
|||
* "0xFFFF" - Hexadecimal |
|||
* "0xFFGF" - Is this invalid hexidecimal? |
|||
* "01677" - This could be an octal number |
|||
* "01678" - This could be an invalid octal number |
|||
* "0b10101000" - Could be a binary number |
|||
* "0b10102010" - This is probably an invalid binary number |
|||
* "10101000b" - This is a binary number in an alternative notation |
|||
* "10101020b" - This is an invalid binary number |
|||
* "1677o" - This is an octal number in an alternative notation |
|||
* "1678o" - This is an invalid octal number in an alternative notation |
|||
* "1234h" - Hexadecimal alternative notation |
|||
* "FFFFh" - Hexadecimal alternative notation |
|||
* "FFFGh" - This is not a valid hexadecimal number |
|||
* "+27" - The positive number 27 |
|||
* "3+2" - This is an expression |
|||
--[[User:Markhobley|Markhobley]] 16:28, 4 June 2011 (UTC) |
|||
== Objective-C question == |
== Objective-C question == |