Skip to content

Commit

Permalink
Support creation from boolean.
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-kulcsar committed Jun 25, 2024
1 parent 5c731f3 commit fa8de7f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ it eventually will include support for the Blocks interface.

- [X] Change namespace to `BigNum`.
- [X] Add appropriate jsdoc and cleanup documentation.
- [X] Allow creation from boolean.
- [ ] Add annotations to enhance debugger support.
- [ ] Allow `number` arguments to operations where supported.
- [ ] Implement method chaining to support things like `a.multiply(x).add(b).mod(m).mod(p)`.
Expand Down
5 changes: 5 additions & 0 deletions bigint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ namespace BigNum {
return result
}
}
if (typeof arg === 'boolean') {
return arg == false ?
zero() :
fromDouble(1)
}

throw `Cannot convert ${arg} (type ${typeof arg}) to BigInt.`
}
Expand Down

0 comments on commit fa8de7f

Please sign in to comment.