| 447 | } |
| 448 | |
| 449 | final static class LongOps implements Ops{ |
| 450 | public Ops combine(Ops y){ |
| 451 | return y.opsWith(this); |
| 452 | } |
| 453 | |
| 454 | final public Ops opsWith(LongOps x){ |
| 455 | return this; |
| 456 | } |
| 457 | |
| 458 | final public Ops opsWith(DoubleOps x){ |
| 459 | return DOUBLE_OPS; |
| 460 | } |
| 461 | |
| 462 | final public Ops opsWith(RatioOps x){ |
| 463 | return RATIO_OPS; |
| 464 | } |
| 465 | |
| 466 | final public Ops opsWith(BigIntOps x){ |
| 467 | return BIGINT_OPS; |
| 468 | } |
| 469 | |
| 470 | final public Ops opsWith(BigDecimalOps x){ |
| 471 | return BIGDECIMAL_OPS; |
| 472 | } |
| 473 | |
| 474 | public boolean isZero(Number x){ |
| 475 | return x.longValue() == 0; |
| 476 | } |
| 477 | |
| 478 | public boolean isPos(Number x){ |
| 479 | return x.longValue() > 0; |
| 480 | } |
| 481 | |
| 482 | public boolean isNeg(Number x){ |
| 483 | return x.longValue() < 0; |
| 484 | } |
| 485 | |
| 486 | final public Number add(Number x, Number y){ |
| 487 | return num(Numbers.add(x.longValue(),y.longValue())); |
| 488 | } |
| 489 | |
| 490 | final public Number addP(Number x, Number y){ |
| 491 | long lx = x.longValue(), ly = y.longValue(); |
| 492 | long ret = lx + ly; |
| 493 | if ((ret ^ lx) < 0 && (ret ^ ly) < 0) |
| 494 | return BIGINT_OPS.add(x, y); |
| 495 | return num(ret); |
| 496 | } |
| 497 | |
| 498 | final public Number unchecked_add(Number x, Number y){ |
| 499 | return num(Numbers.unchecked_add(x.longValue(), y.longValue())); |
| 500 | } |
| 501 | |
| 502 | final public Number multiply(Number x, Number y){ |
| 503 | return num(Numbers.multiply(x.longValue(), y.longValue())); |
| 504 | } |
| 505 | |
| 506 | final public Number multiplyP(Number x, Number y){ |
nothing calls this directly
no outgoing calls
no test coverage detected