English, asked by MalayaDhal, 3 months ago

What will be the output in Java?
Q. Math.round(4.5)
♥︎ Solve this fast♠︎​

Answers

Answered by anindyaadhikari13
6

Answer:

  • Output of Math.round(4.5) is - 5.0

Explanation:

The Math.round() function is used to round off the number to its nearest integer.

For +ve numbers:

  • If the fractional part of the number is >0.0 and <0.5, the function returns the integer part of the number. For example, Math.round(4.4)=4.0
  • If the fractional part of the number is greater than or equal to 0.5, then the function returns the next integer. For example, Math.round(8.5)=9.0, Math.round(8.9)=9.0

For -ve number:

  • If the fractional part of the number is >0.0 and <=0.5, the function returns the integer part of the number. For example, Math.round(-4.4)=-4.0, Math.round(-4.5)=-4.0
  • If the fractional part of the number is greater than or equal to 0.5, then the function returns the next lower integer. For example, Math.round(-8.6)=-9.0, Math.round(-8.9)=-9.0
Answered by shivamkumarsharma343
0

Answer:

Answer is ---> 5

Mark me as Brainless !

Similar questions