[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:
Matthew Jason Benson 2007-11-29 16:25:54 +00:00
parent dab1bdfc0f
commit 673385b43d
1 changed files with 3 additions and 0 deletions

View File

@ -463,6 +463,9 @@ public final class Fraction extends Number implements Comparable {
* @return a new reduced fraction instance, or this if no simplification possible
*/
public Fraction reduce() {
if (numerator == 0) {
return equals(ZERO) ? this : ZERO;
}
int gcd = greatestCommonDivisor(Math.abs(numerator), denominator);
if (gcd == 1) {
return this;