(Contents)(Previous)(Next)

Dimension and~Precision of Numerical Values

The functions SCALE, ROUND, and TRUNC edit numerical values before they are inserted into the database.

The SCALE option can be used to load fixed point numbers that have no explicit decimal point but implicitly are assumed to have one at a certain position.

The SCALE option is also used to load numerical values that are stored in the file in another decimal scale dimension than in the database. Example: kilogram values, possibly with a decimal point, are to be loaded as gram values.

The scaling factor, which is specified after the keyword SCALE, can be positive or negative. The value to which the function refers is multiplied by the corresponding decimal power.

The functions ROUND and TRUNC determine the fractional digits of a number. The number n of fractional digits must lie between 0 and 18. If the number has no fractional digits, the functions have no effect. Floating point numbers are internally converted into fixed point representation.

TRUNC n means that the n+1st and all the following fractional digits of the number are 0, while the first n fractional digits remain unchanged.

ROUND n means that the number is rounded starting with the n+1st fractional digit. If this digit is greater than or equal to 5, the nth digit will be incremented by 1. Also in this case, the result is a number with the n+1st and all the following fractional digits equal to 0; the first digits of the number, however, may be modified by rounding up.

Both ROUND and TRUNC can be applied in combination with the SCALE function. The functions must be specified in the following order: SCALE before ROUND or TRUNC. The order of processing corresponds to this order.

Example:

DATALOAD TABLE distance

...

cm 20-25 SCALE 2

km 20-25 SCALE -3 ROUND 0

...

INFILE meter.input

These three functions are allowed in the field descriptions of DATALOAD, FASTLOAD, and DATAUPDATE statements.


(Contents)(Previous)(Next)