User talk:Tim.Landscheidt/Template:IsNumber

14034
Per 14034#c5, the problem is, what you might consider shortcomings. Would IsNumber be used to validate input for #expr and #ifexpr? If so, that is what #iferror does (rather, it checks if all input was valid after the fact).

If however you wish to validate input for another reason, then what exactly are your requirements? I mean,  might be considered a valid number, but not according to #expr (nor almost any output of 0 ). And should exponent shorthand such as  be? It is according to #expr. In,  returns true of course, because #expr is able to resolve it as   ...   fails an ifeq because it is modified to  , likewise   becomes. #iferror should work for all valid #expr input, with the shortcoming that it also resolves expressions.

But, to put it another way, which of these should return true for #ifnumber?

12345 1‮2345‭ 123 45 123E+45 123 E+45 123E+ 45 123,456,789 123.456.789 123,456.78 123.456,78 12345 12345 -12345 - 12345 +12345 + 12345 .012345 0.012345 123 + 45 123 - 45 123 ^ 45 123 % 45 123 mod 45

Splarka 21:01, 8 May 2008 (UTC)


 * I don't know how you achieved the the first line/two lines so I will ignore it for a moment. I would like to have the following to test positive: "123456.789", " 12345", "12345", "-12345", "- 12345", "+12345", "+ 12345" and "0.012345". If "123E+45", "123E+ 45" and ".012345" would test positive as well, I could live with that. Or, in a Perlish regex, my basic pattern would be "\s*([-+]\s*)?\d+(\.\d+)?\s*". As stated, my goal is to prevent the editor from supplying pseudo-ranges (123-45) and similar errors hard to detect. Tim Landscheidt 23:22, 8 May 2008 (UTC)