Anonymous user
Determine if a string is numeric: Difference between revisions
m
Spelling/grammar/aesthetics, removed extra links
(→{{header|J}}: Minor code simplification.) |
m (Spelling/grammar/aesthetics, removed extra links) |
||
Line 91:
=={{header|C}}==
Returns true (non-zero) if character-string parameter represents a signed or unsigned integer. Otherwise returns false (zero).
#include <stdlib.h>
Line 346 ⟶ 345:
Quoting from [http://perldoc.perl.org/perlfaq4.html#How-do-I-determine-whether-a-scalar-is-a-number%2fwhole%2finteger%2ffloat%3f perlfaq4]:
''How do I determine whether a
Assuming that you don't care about [[IEEE]] notations like "NaN" or "Infinity", you probably just want to use a [[regular expression]].
Line 359 ⟶ 358:
{ print "a C float\n" }
There are also some commonly used modules for the task.
If you're on a [[POSIX]] system, Perl supports the "
sub getnum {
Line 379 ⟶ 378:
sub is_numeric { defined getnum($_[0]) }
Or you could check out the String::Scanf module on the CPAN instead.
=={{header|PHP}}==
|