### Discussion :: Java.lang Class - General Questions (Q.No.1)

Swathi said: (Nov 13, 2011) | |

I have satisfied with this question and answers. |

Sandesh said: (Nov 30, 2012) | |

What if only math.round(2.5); ? |

Kavitha said: (Jan 27, 2014) | |

I have one doubt. If Math.round () returns 0 then the answer may become 2.5 also is it correct or wrong? |

Arijit Paul said: (Feb 11, 2014) | |

@Kavitha. Math.random() "Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0." Thus 2.5 + Math.random() will always be inside [2.5 to 3.5] range. If the fractional portion of number is .5 or greater, the Math.round()rounded to the next higher integer. If the fractional portion of number is less than .5, the argument is rounded to the next lower integer. So, The Math.round() of any number within this range[2.5 to 3.5] is 3. |

Ashish said: (Aug 14, 2014) | |

How I can check it out in my program ? |

Pradeepsai.K said: (Oct 21, 2016) | |

I agree with @Arijit Paul. |

#### Post your comments here:

Name *:

Email : (optional)

» Your comments will be displayed only after manual approval.