korlibs / korlibs/korlibs-bignumber
[Request] Allow to init BigInt with signum and byte array
- Dominant language
- Kotlin
- Stars
- 0
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Like the JVM BigInteger, it would be greate to support this constructor. JVM doc:
```
/**
* Translates the sign-magnitude representation of a BigInteger into a
* BigInteger. The sign is represented as an integer signum value: -1 for
* negative, 0 for zero, or 1 for positive. The magnitude is a byte array
* in big-endian byte-order: the most significant byte is the
* zeroth element. A zero-length magnitude array is permissible, and will
* result in a BigInteger value of 0, whether signum is -1, 0 or 1. The
* {@code magnitude} array is assumed to be unchanged for the duration of
* the constructor call.
*
* @param signum signum of the number (-1 for negative, 0 for zero, 1
* for positive).
* @param magnitude big-endian binary representation of the magnitude of
* the number.
* @throws NumberFormatException {@code signum} is not one of the three
* legal values (-1, 0, and 1), or {@code signum} is 0 and
* {@code magnitude} contains one or more non-zero bytes.
*/
public BigInteger(int signum, byte[] magnitude) {
this(signum, magnitude, 0, magnitude.length);
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Locate the BigInt implementation and its existing constructors, then compare the requested API with the JVM BigInteger documentation included here. Done means supporting signum and big-endian magnitude inputs, including zero-length magnitudes and the documented invalid-value cases; run the repository's relevant tests afterward.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100