Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Divison

Former Member
0 Likes
521

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

3 REPLIES 3
Read only

Former Member
0 Likes
497

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..

Read only

former_member156446
Active Contributor
0 Likes
497

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.

Read only

Former Member
0 Likes
497

Hi,

You can use Ceil and floor statements.

Thanks,

Sriram Ponna