From c636289d3c44bc91e879f2ce689ffadb6ba45355 Mon Sep 17 00:00:00 2001 From: Arthur Drobot Date: Mon, 7 Aug 2017 13:41:45 -0700 Subject: [PATCH] Modify some functions in PreciseNumber for consistency. --- .../java/org/nwapw/abacus/number/PreciseNumber.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/nwapw/abacus/number/PreciseNumber.java b/src/main/java/org/nwapw/abacus/number/PreciseNumber.java index abc657f..7d288b7 100755 --- a/src/main/java/org/nwapw/abacus/number/PreciseNumber.java +++ b/src/main/java/org/nwapw/abacus/number/PreciseNumber.java @@ -113,19 +113,18 @@ public class PreciseNumber extends NumberInterface { String str = value.toPlainString(); int decimalIndex = str.indexOf('.'); if (decimalIndex != -1) { - return new PreciseNumber(str.substring(0, decimalIndex)); + NumberInterface floor = new PreciseNumber(str.substring(0, decimalIndex)); + if(signum() == -1){ + floor = floor.subtract(ONE); + } + return floor; } return this; } @Override public NumberInterface fractionalPartInternal() { - String str = value.toPlainString(); - int decimalIndex = str.indexOf('.'); - if (decimalIndex != -1) { - return new PreciseNumber(str.substring(decimalIndex + 1)); - } - return ZERO; + return this.subtractInternal(floorInternal()); } @Override