contents.gifindex.gifprev1.gifnext1.gif

5.1.8 Floating-Point Data

A floating-point item is a numeric data item that allows for a very wide range of values. However, compared to other numeric data types in COBOL, floating-point data is less accurate. Most computer languages use floating-point to represent non-integer values. This makes floating-point a good method for sharing non-integer data with these other languages.

Floating-point data items differ in several ways from normal numeric data items:

gt490000.gif Floating-point items are stored in a machine-dependent format. In particular, they are stored in a format that is "native" to each machine. There are many floating-point formats currently in use by different machines, so floating-point data should not be considered portable.

gt490000.gif Floating-point items do not have a picture associated with them. Instead, floating-point items are either 4 or 8 bytes in size. The size of the item determines the range of values it can hold.

gt490000.gif The range of values that can be stored in a floating-point item is machine-dependent.

Because floating-point items do not maintain accuracy very well, you should limit their use. Some examples where floating-point is appropriate are:

gt490000.gif You need to share non-integer data with another language such as C or FORTRAN.

gt490000.gif You need to hold very large or very small values that exceed the usual 18 digits available in COBOL.

gt490000.gif You need to process existing data that contains floating-point values.