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)
| 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. |