Question:

In JavaScript, the value returned by Math.ceil(3.14) will be:

Show Hint

Remember: ceil stands for ceiling (going up to the roof), floor means going down to the ground, and round means taking the closest path.
Updated On: Jun 29, 2026
  • 3
  • 3.14
  • 4
  • 2
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation



Step 1: Analyzing the Math.ceil()
Function:
The Math.ceil(x) (ceiling) function rounds its argument $x$ upward to the nearest larger mathematical integer. $$\text{Math.ceil}(x) = \lceil x \rceil = \min \{ n \in \mathbb{Z} \mid n \ge x \}$$

Step 2: Comparing with Other Rounding Functions:

To understand this better, let's look at the three primary rounding methods in JavaScript for the value $3.14$:
{Math.floor(3.14): Rounds downward to the nearest integer $\rightarrow 3$.
{Math.round(3.14): Rounds to the nearest integer mathematically ($\ge 0.5$ rounds up, $< 0.5$ rounds down) $\rightarrow 3$.
{Math.ceil(3.14): Rounds upward to the nearest larger integer, regardless of the decimal fraction value $\rightarrow 4$.

Step 3: Conclusion:

Because $3.14$ has a decimal component, rounding up moves it to the next larger integer, which is $4$.
Was this answer helpful?
0
0