Skip to content

Commit f0160b7

Browse files
committed
Add truncate function to round towards zero.
1 parent bd9b089 commit f0160b7

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/bigfloat.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,17 @@ export class BigFloat {
462462
return(this.addSub(subtrahend, 1));
463463
}
464464

465+
/** Round towards zero, to given number of base 2^32 fractional digits. */
466+
467+
truncate(fractionLimbCount: number) {
468+
if(this.fractionLen > fractionLimbCount) {
469+
this.limbList = this.limbList.slice(this.fractionLen - fractionLimbCount);
470+
this.fractionLen = fractionLimbCount;
471+
}
472+
473+
return(this);
474+
}
475+
465476
/** Divide by integer, replacing current value by quotient. Return integer remainder. */
466477

467478
private divInt(divisor: number) {

0 commit comments

Comments
 (0)