Don't construct zero length big integer
This commit is contained in:
parent
3952067366
commit
add14f1733
@ -607,9 +607,14 @@ class ImpreciseFraction @JvmOverloads constructor(whole: BigInteger, decimal: Do
|
||||
@JvmStatic
|
||||
fun fromByteArray(input: ByteArray): ImpreciseFraction {
|
||||
val size = unsignedInt(input[0])
|
||||
|
||||
if (size > 0) {
|
||||
val slice = input.copyOfRange(1, 1 + size)
|
||||
val bits = bytesToLongBE(input, 1 + size)
|
||||
return ImpreciseFraction(BigInteger(slice), Double.fromBits(bits))
|
||||
} else {
|
||||
return ImpreciseFraction(BigInteger.ZERO, Double.fromBits(bytesToLongBE(input, 1)))
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
|
Loading…
Reference in New Issue
Block a user