Numeric Functions
awk provides the elementary numeric functions listed in Table 9-5Table 9-5. Most of them are common to many programming languages, and their accuracy depends on the quality of the underlying native mathematical-function library.
Table 9-6. Elementary numeric functions
Function | Description |
---|---|
| Return the arctangent of
|
| Return the cosine of |
| Return the exponential of
|
| Return the integer part of
|
| Return the natural logarithm of
|
| Return a uniformly distributed pseudorandom number, r, such that 0 r < 1. |
| Return the sine of |
| Return the square root of
|
| Set the pseudorandom-number generator seed to
|
The pseudorandom-number generator functions rand()
and srand(
)
are the area of largest variation in library functions in
different awk implementations because some of them use native system-library functions instead of their own code, and the pseudorandom-number generating algorithms and precision vary. Most algorithms for generation of such numbers step through a sequence from a finite set without repetition, and the sequence ultimately ...
Get Classic Shell Scripting 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.