Reviewer needed: 6282196 There should be Math.mod(number, modulo) methods

Joseph Darcy joe.darcy at oracle.com
Tue Apr 17 02:10:11 UTC 2012


Hi Roger,

In a case like this where the Math and StrictMath versiosn of a method 
have exactly the same behavior defined, I strongly suggest having the 
Math version of the test invoke tests for both Math and StrictMath 
siblings of a method.  In other words, have a single

     test/java/lang/Math/DivModTests.java

file testing both Math and StrictMath methods; this should ease 
maintenance of the tests going forward.  Otherwise the code looks fine.  
However, I suggest adding a short paragraph to discuss the div & mod 
methods to explain how div and mod are related (mod is paired to div so 
that (a div b) * b + (a mod b) = a) and floor div and floor mod how they 
differ from the built-in / and % operators.

Thanks,

-Joe

On 4/16/2012 2:08 PM, Roger Riggs wrote:
> Hi,
>
> I've corrected a number of issues raised with javadoc in java.lang.Math
> and java.lang.StrictMath.  The updated webrev is:
>  http://cr.openjdk.java.net/~rriggs/6282196.2/
>
> Please review.
>
> Thanks, Roger
>
>
> On 03/05/2012 08:38 AM, Roger Riggs wrote:
>> CR 6282196 There should be Math.mod(number, modulo) methods
>>   http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6282196
>>
>> Requests that floor and modulus methods be provided for primitive types.
>> Floor division is pretty straight-forward, rounding toward minus 
>> infinity.
>> For modulus of int and long, the sign and range follow  the exiting 
>> floor method
>> in java.util.Math and satisfy the relation that mod(x, y) = (x - 
>> floorDiv(x, y) * y).
>>



More information about the core-libs-dev mailing list