2007 Dec 24 2:42 PM
Hi Friends,
I am using the divison operator. everytime the result is 1.5 it gives me 2 but i want the result as 1.
suppose i divide 9 / 6 it gives result as 2 but i want it as 1.Please tell me how can i get this.
thanks in advance
hi lalit,
please make sure that the variables that you are using for calculations are allowing you to work with decimal positions.
you can use the following example for your reference :
DATA: PACK TYPE P DECIMALS 4,
N TYPE F VALUE '+5.2',
M TYPE F VALUE '+1.1'.
PACK = N / M.
WRITE PACK.
PACK = N DIV M.
WRITE / PACK.
PACK = N MOD M.
WRITE /PACK.
The output appears as follows:
4.7273
4.0000
0.8000
This example shows the different types of division.
reward points if useful..
2007 Dec 24 2:54 PM
hi lalit,
please make sure that the variables that you are using for calculations are allowing you to work with decimal positions.
you can use the following example for your reference :
DATA: PACK TYPE P DECIMALS 4,
N TYPE F VALUE '+5.2',
M TYPE F VALUE '+1.1'.
PACK = N / M.
WRITE PACK.
PACK = N DIV M.
WRITE / PACK.
PACK = N MOD M.
WRITE /PACK.
The output appears as follows:
4.7273
4.0000
0.8000
This example shows the different types of division.
reward points if useful..
2007 Dec 24 3:51 PM
hi Lalit
ur issue is because you might have declared the 9 and 6 as type i or type n...
do it at 9_var type p decimal 2/3.
and the result also need to be declared as P with decimals.
type N and I will round ur values.
2007 Dec 24 5:05 PM
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |