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

Type P issue

Former Member
0 Likes
1,469

Hello gurus,

I am dividing 0.7600 by 1000 --- the value shoud be 0.00076

The variable in which this value is calculated is type P decimal 6.

Now after dividing i get a value equals 0.000008.

I dont know how to go abt it.

also when i changed the type of the variable to F then i got an exponential value in the output.

Please help me.

Regards,

Roshan Lilaram Wadhwani.

1 ACCEPTED SOLUTION
Read only

JozsefSzikszai
Active Contributor
0 Likes
1,438

Program Attributes ==> Fixed point arithmetic is checked?

14 REPLIES 14
Read only

Former Member
0 Likes
1,438

Hi,

Welcome to SDN.

declare type P decimal 9 in place of type P decimal 6.

Regards,

Anirban

Read only

0 Likes
1,438

Sorry sir,

On trying that i was getting a value 0.000000008.

If you dont mind then can i ask you on what basis did you ask me to change it to 9, does this type P works on multiples of 3???

Regards,

Roshan.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,438

I'm not seeing the same behavoir, this code outputs 0.000760

data: p type p DECIMALS 6 value '0.7600'.

p = p / 1000.

write:/ p .

Regards,

Rich Heilman

Read only

0 Likes
1,438

Hello,

Thanks for replying to my query.

kalc-value = 0.7600

ekpo-peinh = 1000

gv_unitprice = KALC-VALUE / EKPO-PEINH .

This is my basic requirement.

here i am unable to get that 0.000760

Read only

0 Likes
1,438

kalc-value has 4 decimal places in Data Dictionary. How did you define it in your program?

Read only

0 Likes
1,438

Hello,

Actually this program is a copy of the standard program.

We are directly using it, we have not defined it explicitly.

Regards,

Roshan.

Read only

JozsefSzikszai
Active Contributor
0 Likes
1,439

Program Attributes ==> Fixed point arithmetic is checked?

Read only

0 Likes
1,438

Hello,

Thanks for the reply.

Fixed point arithmetic is not checked

Regards,

Roshan.

Read only

0 Likes
1,438

tha pls. check and try agaon. also check the definition of calc-value!

Read only

0 Likes
1,438

Hello,

Sir, This is an include program, we dont have that option there and in the main program it is not checked.

KALC-VALUE is a standard field with decimal places 4.

Regards,

Roshan.

Read only

0 Likes
1,438

>

> KALC-VALUE is a standard field with decimal places 4.

in this case, there is no chance, the value of 0.00076 will be automatically rounded to 0....8 by the system (because of the 4 decimals).

you say the copied program still using the standard include? probably you can copy the include as well and make the necessary modifications

Read only

0 Likes
1,438

Hello,

Sorry to offend you but what exactly do you mean by " there is no chance, the value of 0.00076 will be automatically rounded to 0....8 by the system (because of the 4 decimals)."

should i transfer the below two variables to decimal 6 local variables and then they shoud be divided.

kalc-value = 0.7600

ekpo-peinh = 1000

gv_unitprice = KALC-VALUE / EKPO-PEINH .

Regards,

Roshan Lilaram.

Read only

0 Likes
1,438

It looks like, your main program does not have the "Fixed Point Airtmetic" checkbox set in the Program > Attributes.


data: gv_unitprice type p decimals 8,
      l_value      type p decimals 4,
      l_peinh      type ekpo-peinh.

l_value = '0.7600'.
l_peinh = 1000.

gv_unitprice = l_VALUE / l_PEINH .
write: gv_unitprice.

With the "Fixed Point Airthmetic" checkbox set, I got the this result:


      0.00076000 

Without the "Fixed Point Airthmetic" checkbox set, I got the this result:


      0.00000008

Regards,

Naimesh Patel

Read only

Former Member
0 Likes
1,438

Hello Roshan.

In Agreement with Rich.

His code works fine and may be you might have divided with something else which has given you "0.000008"

Good Luck & Regards.

Harsh Dave