| 528 | } |
| 529 | |
| 530 | public Number divide(Number x, Number y){ |
| 531 | long n = x.longValue(); |
| 532 | long val = y.longValue(); |
| 533 | |
| 534 | if(n == Long.MIN_VALUE || val == Long.MIN_VALUE) |
| 535 | return BIGINT_OPS.divide(x, y); |
| 536 | |
| 537 | long gcd = gcd(n, val); |
| 538 | if(gcd == 0) |
| 539 | return num(0); |
| 540 | |
| 541 | n = n / gcd; |
| 542 | long d = val / gcd; |
| 543 | if(d == 1) |
| 544 | return num(n); |
| 545 | if(d < 0) |
| 546 | { |
| 547 | n = -n; |
| 548 | d = -d; |
| 549 | } |
| 550 | return new Ratio(BigInteger.valueOf(n), BigInteger.valueOf(d)); |
| 551 | } |
| 552 | |
| 553 | public Number quotient(Number x, Number y){ |
| 554 | return num(x.longValue() / y.longValue()); |