This chapter introduces some basic concepts relating to how computers
do arithmetic and defines some important terms. It then proceeds to describe floating-point arithmetic, which
awk uses for all its
computations, including a discussion of arbitrary-precision floating-point
arithmetic, which is a feature available only in
gawk. It continues on to present
arbitrary-precision integers, and concludes with a description of some
gawk and the POSIX standard
are not quite in agreement.
Most users of
gawk can safely
skip this chapter. But if you want to do scientific calculations with
gawk, this is the place to be.
Until now, we have worked with data as either numbers or strings. Ultimately, however, computers represent everything in terms of binary digits, or bits. A decimal digit can take on any of 10 values: zero through nine. A binary digit can take on any of two values, zero or one. Using binary, computers (and computer software) can represent and manipulate numerical and character data. In general, the more bits you can use to represent a particular thing, the greater the range of possible values it can take on.
Modern computers support at least two, and often more, ways to do arithmetic. Each kind of arithmetic uses a different representation (organization of the bits) for the numbers. The kinds of arithmetic that interest us are: