MCPcopy Create free account
hub / github.com/apache/tomcat / mod

Method mod

java/org/apache/el/lang/ELArithmetic.java:327–347  ·  view source on GitHub ↗

Compute the modulo of two objects, coercing them to the appropriate numeric type. @param obj0 The dividend @param obj1 The divisor @return The result of the modulo operation

(final Object obj0, final Object obj1)

Source from the content-addressed store, hash-verified

325 * @return The result of the modulo operation
326 */
327 public static Number mod(final Object obj0, final Object obj1) {
328 if (obj0 == null && obj1 == null) {
329 return Long.valueOf(0);
330 }
331
332 final ELArithmetic delegate;
333 if (BIGDECIMAL.matches(obj0, obj1)) {
334 delegate = DOUBLE;
335 } else if (DOUBLE.matches(obj0, obj1)) {
336 delegate = DOUBLE;
337 } else if (BIGINTEGER.matches(obj0, obj1)) {
338 delegate = BIGINTEGER;
339 } else {
340 delegate = LONG;
341 }
342
343 Number num0 = delegate.coerce(obj0);
344 Number num1 = delegate.coerce(obj1);
345
346 return delegate.mod(num0, num1);
347 }
348
349 /**
350 * Subtract two objects, coercing them to the appropriate numeric type.

Callers 2

testMod01Method · 0.95
getValueMethod · 0.95

Calls 3

coerceMethod · 0.95
matchesMethod · 0.65
valueOfMethod · 0.45

Tested by 1

testMod01Method · 0.76