[LANG-380]
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@599500 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
dab1bdfc0f
commit
673385b43d
|
@ -463,6 +463,9 @@ public final class Fraction extends Number implements Comparable {
|
||||||
* @return a new reduced fraction instance, or this if no simplification possible
|
* @return a new reduced fraction instance, or this if no simplification possible
|
||||||
*/
|
*/
|
||||||
public Fraction reduce() {
|
public Fraction reduce() {
|
||||||
|
if (numerator == 0) {
|
||||||
|
return equals(ZERO) ? this : ZERO;
|
||||||
|
}
|
||||||
int gcd = greatestCommonDivisor(Math.abs(numerator), denominator);
|
int gcd = greatestCommonDivisor(Math.abs(numerator), denominator);
|
||||||
if (gcd == 1) {
|
if (gcd == 1) {
|
||||||
return this;
|
return this;
|
||||||
|
|
Loading…
Reference in New Issue