Question

# What is the result of 2^7 in Java? Why does it give this result? What would...

What is the result of 2^7 in Java? Why does it give this result? What would you use to get the result you would have expected before taking this class?

#### Homework Answers

Answer #1

What is the result of 2^7 in Java?

Answer is : 128.0

Why does it give this result?

Math.pow(2,7) return the double value.

Math.pow(first,second); first argument raised to the power of the second argument.

2*2*2*2*2*2*2 = 128.0 return double, Not integer.

What would you use to get the result you would have expected before taking this class?

System.out.println(2*2*2*2*2*2*2); 2 multiply by itself, 7 times( you get the integer result)

Know the answer?
Your Answer:

#### Post as a guest

Your Name:

What's your source?

#### Earn Coins

Coins can be redeemed for fabulous gifts.

##### Not the answer you're looking for?
Ask your own homework help question
ADVERTISEMENT
##### Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

ADVERTISEMENT