March 2018
Beginner to intermediate
416 pages
9h 24m
English
This function is used to examine an argument supplied as a string and returns its numeric value. If the string supplied begins with a leading 0, it is treated as an octal number. If the string begins with a leading 0x, it is treated as a hexadecimal number. The following example illustrates the working strtonum() function:
$ vi strtonum.awkBEGIN { print "Decimal num strtonum(123) : ", strtonum(123) print "Octal num strtonum(0123) : ", strtonum(0123) print "Hexadecimal num strtonum(0x123) : ", strtonum(0x123)}$ awk -f strtonum.awk
The output of the execution of the previous code is as follows:
Decimal num strtonum(123) : 123Octal num strtonum(0123) : 83Hexadecimal num strtonum(0x123) : 291
Apart from the preceding ...
Read now
Unlock full access