Math.pow, sqrt, cbrt, hypot and the Rounding Methods ceil, floor, round and rint (ICSE Class 9)
Updated 18 October 2026 · Fact-checked
The Math class (in java.lang, so no import is needed) gives ready-made methods called with the dot operator: Math.pow(x, y), Math.sqrt(x), Math.cbrt(x) and Math.hypot(a, b) return a double. For rounding, ceil gives the smallest whole number not below the value, floor the largest not above it, round the nearest whole number (half rounds upwards, returning a long) and rint the nearest even whole number on a tie (returning a double).
At the tie 2.5, floor and ceil go down and up, round goes up to 3, but rint goes to the even number 2.0.
Illustration drawn for QuestionBuddy.
Understand pow, sqrt, cbrt, hypot and the Rounding Methods ceil, floor, round and rint
The Math class. It belongs to java.lang, which is imported automatically. Its methods are static, so they are called as Math.methodName(arguments).
Powers and roots (all return double).
- Math.pow(x, y) is x raised to the power y: Math.pow(2, 5) is 32.0 and Math.pow(10, 2) is 100.0.
- Math.sqrt(x) is the square root: Math.sqrt(144) is 12.0.
- Math.cbrt(x) is the cube root: Math.cbrt(27) is 3.0.
- Math.hypot(a, b) is the square root of a squared plus b squared: Math.hypot(3, 4) is 5.0.
Because the results are double, storing them in an int needs a cast: int r = (int) Math.sqrt(25);
Rounding methods.
- Math.ceil(x): the smallest whole number that is not less than x, returned as a double. ceil(4.2) is 5.0; ceil(-2.3) is -2.0; ceil(4.0) is 4.0.
- Math.floor(x): the largest whole number that is not greater than x, as a double. floor(4.9) is 4.0; floor(-2.3) is -3.0.
- Math.round(x): the nearest whole number, with a tie going upwards, returned as a long for a double argument. round(2.4) is 2; round(2.5) is 3; round(-2.5) is -2; round(-2.6) is -3.
- Math.rint(x): the nearest whole number, with a tie going to the even number, returned as a double. rint(2.5) is 2.0; rint(3.5) is 4.0; rint(2.6) is 3.0.
Common traps.
- Integer division inside: Math.ceil(7 / 2) is ceil of 3 (because 7 / 2 is 3), which is 3.0, whereas Math.ceil(7 / 2.0) is 4.0.
- round of a negative tie goes towards the larger number: round(-2.5) is -2.
- Rounding to two decimal places: Math.round(x * 100) / 100.0.
Writing expressions. Replace mathematical powers and roots by method calls: the hypotenuse is Math.sqrt(a * a + b * b); the cube of s is Math.pow(s, 3).
Neighbouring topics: abs, max, min, random and the exact methods are on the next page of this chapter.
pow, sqrt, cbrt, hypot and the Rounding Methods ceil, floor, round and rint: key facts
- Powers and roots
Math.pow x, y Math.sqrt x Math.cbrt x Math.hypot a, b all return double - No import needed: java.lang.
- Rounding
ceil up to a whole number, double floor down, double round nearest, tie upwards, long rint nearest, tie to even, double - round(-2.5) is -2.
- Two decimal places
- Math.round(x times 100) / 100.0 | divide by a decimal, not an int
- Keeps the fraction.
pow, sqrt, cbrt, hypot and the Rounding Methods ceil, floor, round and rint in real life
The idea, met in an everyday situation. Answer the question in your own words, then compare with the model answer. The one-line hook is what to remember.
Ceil and floor in billing
Suppose a taxi charges for every started kilometre and a trip is 7.2 km.
How many kilometres are charged, and how many full kilometres were completed?
Try it first, then show the solutionSolution
- Started kilometres: ceil(7.2) = 8.
- Completed kilometres: floor(7.2) = 7.
Answer: 8 km are charged (ceil) and 7 full kilometres were completed (floor).
Memory hook: Ceil rounds up to the next whole; floor rounds down.
Tricks to remember pow, sqrt, cbrt, hypot and the Rounding Methods ceil, floor, round and rint
Short memory aids. Say each one aloud once, then use it on a question the same day.
Ceil is the ceiling, floor is the floor
ceil goes up, floor goes down, even for negatives: ceil(-2.3) is -2.0.
Use it when: Rounding methods.
Round returns long
Math.round(double) gives a long, rint gives a double.
Use it when: Return types.
Half rounds up
round(2.5) = 3 and round(-2.5) = -2.
Use it when: Ties.
pow, sqrt, cbrt, hypot and the Rounding Methods ceil, floor, round and rint: solved examples
Ordered from board level to HOTS. Try each one before you open the solution.
Example 1: Square root · 1 mark · MCQBoard level
What is the value of Math.sqrt(81)?
(a) 9 (b) 9.0 (c) 8.0 (d) 81.0
Try it first, then show the solutionSolution
- sqrt returns a double, so the value is written 9.0.
Answer: (b) 9.0
Example 2: Powers and roots · 3 marks · Short answerHarder board level
Find the output:
System.out.println(Math.pow(3, 3) + " " + Math.sqrt(121) + " " + Math.cbrt(8) + " " + Math.hypot(8, 15));Try it first, then show the solutionSolution
- 3 to the power 3 is 27, printed as 27.0 because pow returns a double. (1 mark)
- sqrt(121) = 11.0 and cbrt(8) = 2.0. (1 mark)
- hypot(8, 15) = sqrt(64 + 225) = sqrt(289) = 17.0. Output: 27.0 11.0 2.0 17.0. (1 mark)
Answer: 27.0 11.0 2.0 17.0
Example 3: Rounding of negative and tie values · 3 marks · Short answerHarder board level
Find the output:
System.out.println(Math.ceil(-6.8) + " " + Math.floor(-6.8) + " " + Math.round(-6.5) + " " + Math.rint(6.5) + " " + Math.round(6.5));Try it first, then show the solutionSolution
- ceil(-6.8) = -6.0 and floor(-6.8) = -7.0. (1 mark)
- round(-6.5) = -6 (a tie goes upwards) and rint(6.5) = 6.0 (a tie goes to the even number). (1 mark)
- round(6.5) = 7. Output: -6.0 -7.0 -6 6.0 7. (1 mark)
Answer: -6.0 -7.0 -6 6.0 7
Example 4: Case study: writing expressions · 4 marks · Case-basedHOTS / competency
A student writes Java for three formulas.
(i) Hypotenuse for a = 6 and b = 8: Math.sqrt(a * a + b * b). Find its value. (1)
(ii) Volume of a cube of side s = 4: Math.pow(s, 3). Find its value. (1)
(iii) Round the value 7.456 to two decimal places using Math.round and give the result. (2)
Try it first, then show the solutionSolution
- (i) 36 + 64 = 100 and sqrt(100) = 10.0.
- (ii) 4 cubed is 64, so the value is 64.0.
- (iii) Math.round(7.456 * 100) / 100.0: 7.456 x 100 is about 745.6, which rounds to 746; 746 / 100.0 = 7.46.
Answer: (i) 10.0 (ii) 64.0 (iii) 7.46
Example 5: Integer division trap · 3 marks · Short answerHarder board level
Find the output:
System.out.println((int) Math.ceil(7 / 2) + " " + Math.ceil(7 / 2.0));Try it first, then show the solutionSolution
- 7 / 2 is integer division and gives 3, so ceil(3) = 3.0 and the cast makes it 3. (1 mark)
- 7 / 2.0 = 3.5 and ceil(3.5) = 4.0. (1 mark)
- Output: 3 4.0. (1 mark)
Answer: 3 4.0
Where students lose marks in pow, sqrt, cbrt, hypot and the Rounding Methods ceil, floor, round and rint
The slips examiners see most often, and what to write instead.
Mistake: Writing 9 for Math.sqrt(81)
The return type is ignored.
Wrong working
Math.sqrt(81) = 9
Right working
Math.sqrt(81) = 9.0
Do this: The result is a double.
Usually costs: 1 mark
Mistake: Wrong round of negative ties
The sign is ignored.
Wrong working
Math.round(-2.5) = -3
Right working
Math.round(-2.5) = -2
Do this: A tie goes upwards.
Usually costs: 1 mark
Mistake: Integer division inside ceil
Both operands are int.
Wrong working
Math.ceil(7 / 2) = 4.0
Right working
Math.ceil(7 / 2) = 3.0
Do this: Write 7 / 2.0.
Usually costs: 1 mark
Exam tips
- Always write .0 for a double result and no .0 for a long result of round.
- Remember Math is in java.lang: no import is needed.
- Trace nested calls from the inside outwards.
- For rounding to two decimals use Math.round(x * 100) / 100.0.
Practice questions on pow, sqrt, cbrt, hypot and the Rounding Methods ceil, floor, round and rint
Write each answer on paper first. Open the hint only if you are stuck, and the answer only when you have finished.
Q1 · 1 mark · MCQBoard level
Math.floor(5.9) returns:
(a) 5 (b) 6.0 (c) 5.0 (d) 6Hint
floor goes down and returns a double.
Answer
(c) 5.0
Q2 · 2 marks · Very short answerBoard level
A parking lot charges for every started hour. Which Math method gives the number of chargeable hours for 3.2 hours, and what is the value?
Hint
Round up.
Answer
Math.ceil(3.2), which is 4.0 (4 hours are charged).
Q3 · 2 marks · Short answerHarder board level
Evaluate Math.pow(3, 4) / Math.pow(3, 2).
Hint
Both are doubles.
Answer
9.0 (81.0 / 9.0)
Q4 · 3 marks · Short answerHarder board level
Find the value of Math.round(4.5) + Math.round(-4.5) + Math.round(4.4).
Hint
A tie goes upwards.
Answer
5 (round(4.5) = 5, round(-4.5) = -4, round(4.4) = 4; 5 - 4 + 4 = 5)
Q5 · 3 marks · Short answerHOTS / competency
A student writes int x = Math.sqrt(25); and gets an error. Explain and give two corrections.
Hint
What type does sqrt return?
Answer
Math.sqrt returns a double and a double cannot be stored in an int without a cast (possible lossy conversion). Corrections: int x = (int) Math.sqrt(25); or double x = Math.sqrt(25);
Test your recall
Answer in your head or on paper first, then open the card. Pulling an answer out of memory makes it stick far better than re-reading.
1.Is Math.pow(2, 3) 8 or 8.0?Show answer
8.0
2.What does Math.cbrt(27) return?Show answer
3.0
3.What does Math.ceil(4.2) return?Show answer
5.0
4.What does Math.floor(-2.3) return?Show answer
-3.0
5.What does Math.rint(3.5) return?Show answer
4.0
6.Does Math.round(3.7) give 4 or 4.0?Show answer
4, a long value.
pow, sqrt, cbrt, hypot and the Rounding Methods ceil, floor, round and rint: frequently asked questions
Do I need to import java.lang for Math?
No. java.lang is imported automatically.
What is the difference between round and rint?
round sends a tie upwards and returns a long; rint sends a tie to the even number and returns a double.
Can I write Math.sqrt(-4)?
It gives NaN (not a number), because the square root of a negative number is not real.