Programming instructions
47
5.2 Decimal Handling
As mentioned above, the default method for handling decimals is to drop them.
This restriction can be avoided through the setting of the float flag (M8023) and
the use of the floating point instructions in section 5.1 of the FX3U Programming
Manual.
There are 2 formats for displaying decimal numbers: Scientific Notation and
Floating Point Format.
SCIENTIFIC NOTATION
Scientific Notation uses 2 registers to store the mantissa and the
exponent. The mantissa is the first 4 significant digits of a number, and
the exponent shows the position of the decimal. This format cannot be
used in calculations, but is useful for displaying data.
Example: 1,238,900 would be displayed as 1238 x 10
3
. 1238 is the
mantissa and 10
3
which indicates the decimal is 3 places to the right, is
the exponent.
A number between 0 and 1 or 0 and –1 is represented by a negative
exponent. The exponent shows how many places to the left of the
mantissa to locate the decimal.
Example: .00123 would be displayed as 123 x 10
-5
.
This format allows number outside of the normal 32 bit range (~ +/- 2
billion) to be displayed. The number range is 9999 x 10
35
to –9999 x 10
35
.
The trade off is a loss of precision, only 4 significant digits.
The method for storing a scientific notation number: The mantissa is
stored at register D, and the exponent is stored at D+1. In the above
examples, if 1,238,900 were to be stored in D0 and .00123 was stored at
D2, the data registers would appear as follows:
D0 1238
D1 3
D2 123
D3 -5
FLOATING POINT
Similar to the Scientific Notation format, this format displays the number in
register D and register D+1. The mantissa occupies all 16 bits of D and
the first 7 bits of D+1. The exponent occupies the last 9 bits of D+1, with
bit 15 acting as a sign bit.