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
|
@JvmStatic
|
||||||
fun fromByteArray(input: ByteArray): ImpreciseFraction {
|
fun fromByteArray(input: ByteArray): ImpreciseFraction {
|
||||||
val size = unsignedInt(input[0])
|
val size = unsignedInt(input[0])
|
||||||
val slice = input.copyOfRange(1, 1 + size)
|
|
||||||
val bits = bytesToLongBE(input, 1 + size)
|
if (size > 0) {
|
||||||
return ImpreciseFraction(BigInteger(slice), Double.fromBits(bits))
|
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
|
@JvmStatic
|
||||||
|
Loading…
Reference in New Issue
Block a user