Skip to Content
0

Arithmatic Operations

Oct 17, 2017 at 03:49 PM

47

avatar image
Former Member

What is the result of the following arithmetic operation?

DATA: intTYPEI.

int=5*(3/10).

Problem is they are suggesting the correct answer as 0. But how could this be possible. Need guide on this .

Being a newbie, these types of issues is common i think.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Manoj K Oct 17, 2017 at 05:20 PM
0

Hi Shantanu,

By looking at the declaration the query looks related to ABAP. So however if its ABAP/PI(Java) yes the answer is 0.

Go through the operator precedence for ABAP or JAVA . The result of 3/10 is returned as 0 and not 0.3 . If you would have declared the int as type Decimal in ABAP then the value would be 1.5

DATA: int TYPE I.
int=5*(3/10).
Output : 0
DATA: int TYPE P DECIMALS 1.
int=5*(3/10).
Output : 1.5

Br,

Manoj

Share
10 |10000 characters needed characters left characters exceeded
Raghuraman S Oct 17, 2017 at 04:05 PM
0

You wish to execute this in pi mapping?

Manually if you do answer should be 1.5

Share
10 |10000 characters needed characters left characters exceeded