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 cos (expr) function

The cos (expr) function returns the cosine of the expression expr, where expr is expressed in radians. The following code block shows an example of a cosine function:

$ vi cosfunc.awkBEGIN    {    print "cos(90) = ", cos(90);    print "cos(45) = ", cos(45);    }$ awk -f cosfunc.awk

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

cos(90) =  -0.448074cos(45) =  0.525322

The remaining trigonometric functions, such as sec(), cosec(), tan(), and cot(), are measured in radians, and can be obtained with the use of the sin() and cos() functions.

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