Debian Codegraph @

test/forcenum.awk

raw
1 BEGIN {
2 # make some strnums
3 nf = split("|5apple|NaN|-NaN|+NaN| 6|0x1az|011Q|027", f, "|")
4
5 for (i = 1; i <= nf; i++) {
6 # NaN values on some systems can come out with
7 # a sign in front of them. So instead of using %g to
8 # convert the strnum to a double, do it manually, and
9 # then remove any leading sign so that the test will
10 # work across systems.
11 val = f[i] + 0
12 val = val ""
13 val = tolower(val)
14 sub(/^[-+]/, "", val)
15 printf "[%s] -> %s (type %s)\n", f[i], val, typeof(f[i])
16 }
17 }