1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-11-18 00:19:32 -08:00

Modify some functions in PreciseNumber for consistency.

This commit is contained in:
Arthur Drobot 2017-08-07 13:41:45 -07:00
parent 553349133d
commit c636289d3c

View File

@ -113,19 +113,18 @@ public class PreciseNumber extends NumberInterface {
String str = value.toPlainString(); String str = value.toPlainString();
int decimalIndex = str.indexOf('.'); int decimalIndex = str.indexOf('.');
if (decimalIndex != -1) { 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; return this;
} }
@Override @Override
public NumberInterface fractionalPartInternal() { public NumberInterface fractionalPartInternal() {
String str = value.toPlainString(); return this.subtractInternal(floorInternal());
int decimalIndex = str.indexOf('.');
if (decimalIndex != -1) {
return new PreciseNumber(str.substring(decimalIndex + 1));
}
return ZERO;
} }
@Override @Override