Next: , Up: Arbitrary Precision Arithmetic

15.1 A General Description of Computer Arithmetic

Within computers, there are two kinds of numeric values: integers and floating-point. In school, integer values were referred to as “whole” numbers—that is, numbers without any fractional part, such as 1, 42, or −17. The advantage to integer numbers is that they represent values exactly. The disadvantage is that their range is limited. On most systems, this range is −2,147,483,648 to 2,147,483,647. However, many systems now support a range from −9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.

Integer values come in two flavors: signed and unsigned. Signed values may be negative or positive, with the range of values just described. Unsigned values are always positive. On most systems, the range is from 0 to 4,294,967,295. However, many systems now support a range from 0 to 18,446,744,073,709,551,615.

Floating-point numbers represent what are called “real” numbers; i.e., those that do have a fractional part, such as 3.1415927. The advantage to floating-point numbers is that they can represent a much larger range of values. The disadvantage is that there are numbers that they cannot represent exactly. awk uses double precision floating-point numbers, which can hold more digits than single precision floating-point numbers.

There a several important issues to be aware of, described next.