public double hypotenuse()
{
//return Math.hypot(leg, leg); //returns 7.0710678118654755
//return 0.1 * Math.floor(Math.hypot(leg, leg) * 10); //returns 7.0
//return 0.1 * Math.ceil(Math.hypot(leg, leg) * 10); //returns 7.1000000000000005
return 0.1 * Math.round(Math.hypot(leg, leg) * 10); //returns 7.1000000000000005
}
I am trying to round to the nearest 10th place, so this number should round up to 7.1. Why does this method work with Math.floor but not with Math.round? Does anyone have any insight?
Thanks,
Sky