Skip to content

Commit 20011ad

Browse files
✨ feat(Integer): Add draft implementation for divround.
1 parent 95f683e commit 20011ad

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Integer.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,12 @@ export class Integer {
267267
return this.modn(number).move(this);
268268
}
269269

270+
divround ( other ) {
271+
const [ q , r ] = this.divmod(other) ;
272+
if ( r >= ( this.base / 2 | 0 ) ) increment( r , q.limbs , 0 , q.limbs.length ) ;
273+
return q ;
274+
}
275+
270276
divmod ( other ) {
271277

272278
if ( other.iszero() ) throw new ZeroDivisionError( 'Integer division by zero' ) ; // optimize

0 commit comments

Comments
 (0)