O'Reilly logo

Learning AWK Programming by Shiwang Kalkhanda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The lshift (val, count) function

The Ishift function returns the value of val, shifted to the left side by the count number of bits specified in the argument. 0s are shifted in from the right side. For example, let us left shift, or lshift, the decimal 5  once to illustrate how the lshift() function works:

5 = 101

lshift once = 1010, which is decimal 10

The following example shows how the lshift() functions work:

$ vi lshift.awkBEGIN    {    num1 = 5    count =1     result = lshift(num1,count)    printf "lshift(%d,%d) = %d\n", num1, count, result
}$ awk -f lshift.awk

The output of the execution of the previous code is as follows:

lshift(5,1) = 10

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required