Computer Applications
Give the output of the following:
- Math.floor (-4.7)
- Math.ceil(3.4) + Math.pow(2, 3)
Java
Java Math Lib Methods
ICSE 2018
36 Likes
Answer
- -5.0
- 12.0
Math.floor method returns the largest double value that is less than or equal to the argument and is equal to a mathematical integer. As -5.0 is the largest mathematical integer less than -4.7 so it is the output. Note that -4.7 is a negative number so the largest integer less than -4.7 is -5.0 and not -4.0.
Math.ceil(3.4) gives 4.0 and Math.pow(2,3) gives 8.0. So the output is 4.0 + 8.0 = 12.0.
Answered By
16 Likes
Related Questions
The output of the following code is:
System.out.println(Math.ceil(6.4) + Math.floor(-1-2));- 3.0
- 4
- 3
- 4.0
The output of the statement
Math.ceil.(89.9) + Math.floor(90.5)is:- 0.0
- 180
- 180.0
- 180.4
Give the output of the following:
Math.sqrt(Math.max(9,16))What is the output of Math.ceil(5.4)+Math.ceil(4.5)?
- 10.0
- 11.0
- 12.0
- 9.0