Computer Science, asked by ashish0734, 7 months ago

difference between Math. round and Math. rint​

Answers

Answered by mamtasinha324
1

Explanation:

Difference is at .

Math. rint() returns double. So it can be said that Math. round() favors mid-point(0.5) for higher value.

Answered by TeacherUnknow
54

\huge\mathbb{\underline{\underline{PROBLEM:}}}

 \huge☞

 \bold{Difference  \: between  \: Math  \: round}  \\  \bold{ and  \: Math \:  rint}

\huge\mathbb{ANSWER:}

\huge╭☞Math. round accepts both double s and float s, and has varying return types for some reason ( long and int respectively, which are the smallest type large enough to cover the entire range represented by the parameter). Math. rint accepts double s and returns double s.It is less "destructive" than Math.

\bold{Example \:  of } \: \\   \bold{Math. \:  round:}

  • round() , rather than as a method of a Math object you created ( Math has no constructor). Examples. Using round.

\bold{Example \:  of} \\ \bold{Math. rint: }

  • Math rint() method returns a value that is closest to the specified value and is equal to the mathematical integer. ... And, for value 5.4, the closest value that is equal to mathematical integer is 5.0. The syntax of the rint() method is: Math.rint(double value).

\bold{Note:}

\huge☞The rint() method is a static method.

\huge\mathbb{EXPLANATION:}

\huge╭☞Math.rint() and Math.round() have several differences, but the one which might impact the business logic of a Java application the most is the way they handle rounding of integers which are on a boundary (e.g. 4.5 is on the boundary of 4 and 5).

\\ \\ \\ \\

#BrainliestBunch

Similar questions