A numeric constant stands for a number. It can be an integer, a decimal fraction, or a number in an exponential notation. Some examples of numeric constant values are as follows:
- 100
- 1.10
- 1.05e+2
- 1.05e-1
Any nonzero numeric value in AWK is true in the case of expression evaluation, and zero is false. For example:
$ vi numeric.awk
BEGIN{
if ( 1 )
print "numeric 1 "
if ( 1.234 )
print "numeric 1.234"
if ( 1.234e )
print "numeric 1.234e"
if ( 0 )
print "false"
}
$ awk -f numeric.awk
The output of the execution of the preceding code is as follows:
numeric 1
numeric 1.234
numeric 1.234e