aboutsummaryrefslogtreecommitdiffstats
path: root/awklib/eg/lib/isnumeric.awk
diff options
context:
space:
mode:
Diffstat (limited to 'awklib/eg/lib/isnumeric.awk')
-rw-r--r--awklib/eg/lib/isnumeric.awk14
1 files changed, 14 insertions, 0 deletions
diff --git a/awklib/eg/lib/isnumeric.awk b/awklib/eg/lib/isnumeric.awk
new file mode 100644
index 00000000..6309e76a
--- /dev/null
+++ b/awklib/eg/lib/isnumeric.awk
@@ -0,0 +1,14 @@
+# isnumeric --- check whether a value is numeric
+
+function isnumeric(x, f)
+{
+ switch (typeof(x)) {
+ case "strnum":
+ case "number":
+ return 1
+ case "string":
+ return (split(x, f, " ") == 1) && (typeof(f[1]) == "strnum")
+ default:
+ return 0
+ }
+}