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

finding decimals

Former Member
0 Likes
540

Hi experts

I need a logic to findout how many decimals places in a value.

for example , V_temp = 567.00

v_temp = 1234

v_temp contains 2 decimal places and next one is zero

Thanks in advance

saikar

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
458

Hi Karthik,

Move it to a char variable and seperate text at . into 2 variables, then find the length of the second variable using strlen().

Regards,

Satish

3 REPLIES 3
Read only

Former Member
0 Likes
459

Hi Karthik,

Move it to a char variable and seperate text at . into 2 variables, then find the length of the second variable using strlen().

Regards,

Satish

Read only

Former Member
0 Likes
458

Hi..

write w_value decimals 2.

Example: DATA pack TYPE p VALUE '123.456'

DECIMALS 3.

WRITE pack DECIMALS 2.

WRITE: / pack ROUND -2,

/ pack ROUND -1,

/ pack ROUND 1,

/ pack ROUND 2.

or......

w_pack type p decimals 2.

w_pack = w_value.

write w_pack.

Award points if found helpful.....

Cheers,

Chandra Sekhar.

Read only

Former Member
0 Likes
458

data: moff,len type i.

len = strlen (v_temp).

find '.' in v_temp MATCH OFFSET moff.

moff will have the position of decimal.

subtract dat from actual length of v_temp.

Hope dis helps.

Reward all helpful answers