2008 Apr 18 6:06 AM
Hi Experts,
I have probelem in division with 100
eg if i have a variable 12.87
x=12.87
if i divide this variable by 100
y = 12.87/100
the value becomes 13 , but the requirement is to be 12
the value of y finally should be 12
2008 Apr 18 6:17 AM
Hi,
The result is just rounded ie., 0.1287 is rounded to 0.13.
Also try like:
DATA: y TYPE p DECIMALS 2.
DATA: x TYPE p DECIMALS 2 VALUE '12.87'.
y = x / 100 .
WRITE : y.
Regards...
Hi Experts,
I have probelem in division with 100
eg if i have a variable 12.87
x=12.87
if i divide this variable by 100
y = 12.87/100
the value becomes 13 , but the requirement is to be 12
the value of y finally should be 12
2008 Apr 18 6:13 AM
hi,
If i have understood your requirement correctly ...do this way ...
data : v_x(5) type c value '12.87',
v_y(5) type c,
v_z(5) type c.
SPLIT v_x AT '.' INTO v_y v_z.
write : v_x, v_y, v_z.
2008 Apr 18 6:14 AM
Hi Karthik,
It is rounding off the decimal values and hence making it 13 in your case.
What are the variable types that you declared for X and Y ?
You should be taking the value after division into an integer variable and it shall give you the required number.
Reward points if this helps,
Kiran
2008 Apr 18 6:16 AM
You have to use some math functions here for to get integer value in your final format just use TRUNC key word.
like after dividing you just say:
y = trunc(y).
then you will get integer part means 12.
try this if it useful ..reward.
Dara.
2008 Apr 18 6:17 AM
Hi,
The result is just rounded ie., 0.1287 is rounded to 0.13.
Also try like:
DATA: y TYPE p DECIMALS 2.
DATA: x TYPE p DECIMALS 2 VALUE '12.87'.
y = x / 100 .
WRITE : y.
Regards...
2008 Apr 18 6:25 AM
Hi,
Insted of using y = 12.87/100
you can use y = 12.87 DIV 100.
Then it will return 12.
Definitely it will work.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |