Skip to content

Commit bbf7ee6

Browse files
✨ feat(Integer): Add draft implementation for abs.
1 parent 20011ad commit bbf7ee6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Integer.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,14 @@ export class Integer {
345345
return this.opposite().move(this);
346346
}
347347

348+
abs ( ) {
349+
return this.sign() >= 0 ? this : this.opposite(this) ;
350+
}
351+
352+
iabs ( ) {
353+
return this.sign() >= 0 ? this : this.negate(this) ;
354+
}
355+
348356
sign ( ) {
349357
return this.iszero() ? 0 : this.is_negative ? -1 : 1 ;
350358
}

0 commit comments

Comments
 (0)