7.11. Built-In Arithmetic Functions

Table 7.3 lists the built-in arithmetic functions, where x and y are arbitrary expressions.

Table 7.3. Arithmetic Functions
Name Value Returned
atan2(x,y) Arctangent of y/x in the range.
cos(x) Cosine of x, with x in radians.
exp(x) Exponential function of x, e.
int(x) Integer part of x; truncated toward 0 when x > 0.
log(x) Natural (base e) logarithm of x.
rand( ) Random number r, where 0 < r < 1.
sin(x) Sine of x, with x in radians.
sqrt(x) Square root of x.
srand(x) x is a new seed for rand( ).[a]

[a] From Alfred V. Aho, Brian W. Kernighan, and Peter J. Weinberger, The AWK Programming Language (Boston: Addison-Wesley, 1988).© 1988 Bell Telephone Laboratories, Inc. Reprinted by permission of Pearson Education, ...

Get UNIX® Shells by Example, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.