Thursday, September 1, 2022

Different results when rounding floating points

Java's Math.round(0.5) and C++'s std::round(0.5) result in the value of 1 while Python 3 round(0.5) results in zero because while Java and C++ use round up, Python 3 uses round half to even.

No comments:

Post a Comment