JDK-6282196 : There should be Math.mod(number, modulo) methods
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 5.0,6
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-06-08
  • Updated: 2017-05-16
  • Resolved: 2012-11-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8 b65Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
A DESCRIPTION OF THE REQUEST :
It is sufficiently tricky to do modulo arithmetic on negative integers that methods should be provided in the Math class to do this correctly.

JUSTIFICATION :
A common mistake is to do Math.abs(n) % MODULO.  If there were methods in the library that would do it right, these bugs could be more easily avoided.  I note that BigInteger has a mod() method (presumably for efficiency).
###@###.### 2005-06-08 06:41:24 GMT

Comments
EVALUATION Adding true div and mod methods would help prevent surprising results with the % operator. A fuller solution could also accept a java.math.RoundingMode parameter. ###@###.### 2005-07-19 22:52:10 GMT
19-07-2005