DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Using awk

Using arithmetic functions

awk provides the built-in arithmetic functions shown in ``awk arithmetic functions''.

awk arithmetic functions

Function Value returned
atan2(y,x) arctangent of y/^x in the range -Pi to Pi
cos(x) cosine of x, with x in radians
exp(x) exponential function of x
int(x) integer part of x truncated towards 0
log(x) natural logarithm of x
rand random number between 0 and 1
sin(x) sine of x, with x in radians
sqrt(x) square root of x
srand(x) x is new seed for rand
Both x and y are arbitrary expressions. The function rand returns a pseudo random floating point number in the range (0,1), and srand can be used to set the seed of the generator. If srand has no argument, the seed is derived from the time of day.


Next topic: Using strings and string functions
Previous topic: Functions

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003