# Why MOD has a incorrect result?

We can see:

yyy = ( '608.9200' * ( 10 **2 ) ) mod 1

I don't understand why the result is '1'.

##### Tags:

##### Karl Nikolai Jamoralin replied

Hi Tom,

I tried using this code:

**DATA yyy TYPE p DECIMALS 4.**

** yyy = '608.9200' * ( 10 ** 2 ). WRITE yyy.**

** yyy = yyy MOD 1. WRITE / yyy.**

** yyy = ( '608.9200' * ( 10 ** 2 ) ) MOD 1. WRITE / yyy.**

And the result is this:

**60,892.0000**

** 0.0000**

** 1.0000**

******

It sure is odd; when you perform the operation step by step, it will yield the correct result but if chained, it got some weird results. The remainder can't be 1 for MOD 1.

The cause might be on the calculation type if you look closely at the documentation:

**Determining the Calculation Type **

The calculation type corresponds to one of the numeric data types i, p, f, or decfloat34. It is determined according to the following hierarchy, and in this order of priority:

- If one of the data types involved is decfloat16 or decfloat34, the calculation type is decfloat34.
- If one of the data types involved is f or if the operator ** is used, the calculation type is f.
- If one of the data types involved is p, the calculation type is p.
- If one of the data types involved is i, (b or s), the calculation type is i.

******

Now, the calculation type used in the operation is F, but we need to store it in a P variable. The value of F will be rounded up to the number of decimal places you have in your P variable. Given this and Matthew's reply above regarding the F values, we will arrive to those weird values in question.

Hope this helps!

Regards,

Karl