# Is 31 integer

## Number formats for programmable logic controllers

You can also use decimal floating point numbers (e.g. 3.210) convert into a dual floating point number. It should be noted here that not all decimal places can be represented exactly in dual. You can only display the decimal places exactly, which result from the sum of the negative powers of 2-1 - 2-23 can be formed (with 32 bit).

In the first step, the mantissa of the floating point number is calculated. The formula mantissa = GPZ is used for this10 · ( 2n ), so that the result is this:

This means that the exponent n at (2n) must be selected so that the result for the mantissa has a value between 1 and 2.

If the number for the exponent n is less than -12610 or greater than +12710 is calculated, the number cannot be displayed as SHORT REAL. The result would then be either 0 or infinite and is referred to as NaN, which translated means Not a Number.

In order to avoid negative values, the exponent is offset against the BIAS value, which is 127 for SHORT-Real. Therefore you can only save the exponents in the range -126 to +127, which are saved as a characteristic between 1 - 255. This leaves the values ​​0 and 255. These two values ​​are reserved as characteristics for the numerical values ​​zero and infinity and thus as NaN.

In the second step, the decimal places of the mantissa are displayed in dual. Here you either have the luck that the decimal places are replaced by the sum of the negative powers of 2-1 - 2-23 can be displayed or you can only determine an approximate value. If the mantissa contains a negative power, a 1 is placed in the corresponding position. If a negative power is not included, a 0 is used.

In the third step, the exponent of the floating point number is determined as a binary number. The following formula is used for this:

• Exponent = (y) + (EBias)

E.Bias here is the number 127 that was already used in the example above. E.Bias defines the size of the number range, with 32 bit GPZ2 just through 12710 and with 64 bit GPZ2 it is 102310.

Example for converting the floating point number 3.210

Find the mantissa using the formula GPZ10 · ( 2n ) and selection of the exponent so that the mantissa is obtained in the form 1 <= mantissa <2:

• Mantissa of 3.210 = 3,210 x 2-1 = 1,6

Here the exponent became 2-1 chosen because this puts the result between 1 and 2.

Now the decimal number 0.6 is converted into dual. The decimal number 0.6 cannot be represented exactly in dual, because the number cannot be derived from the sum of the powers of 2-1 - 2-23 can form. So an approximate value is determined. If a power is used, a 1 is written in the mantissa; if a power is not used, a 0 is used.

For converting the decimal place 0.6 it would look like this:

1x2-1 + 0x2-2 + 0x2-3 + 1x2-4 + 1x2-5 + 0x2-6 + 0x2-7 + 1x2-8 + 1x2-9 + 0x2-10 + 0x2-11 + 1x2-12 + 1x2-13 + 0x2-14 + 0x2-15 + 1x2-16 + 1x2-17 + 0x2-18 + 0x2-19 + 1x2-20 + 1x2-21 + 0x2-22 + 1x2-23

• This results in the binary number 100 1100 1100 1100 1100 11012
• The approximate value corresponds to 0.60000002384185791075625
• The mantissa would be: 1 + 0.60000002384185791075625 = 1.60000002384185791075625

This results in the following appearance for the places in the mantissa:

X XXXX XXXX 100 1100 1100 1100 1100 11012

Now the exponent for:

Exponent = (y) + (EBias) for decimal numbers> = 1

Exponent = (- y) + (EBias) for decimal numbers <1

Exponent = 110 + 12710 = 12810

With floating point numbers> = 1, the positive value of the exonent is used for the variable (y), which was used when determining the mantissa GPZ10 · (2-n) as (n) was used. For floating point numbers <1, the negative value of the determined exponent is used.

In this case it will 12810 converted to dual. You get 1000 00002.

Finally, you set the sign bit and you get the following result:

• 0 1000 0000 100 1100 1100 1100 1100 1101

The number is positive, the exponent and the mantissa have been determined. If you convert the dual floating point number into decimal, you get 3.210.