mkrd/Swift-BigInt

Convert hex string to decimal returns null

k2evil opened this issue · 3 comments

let w = BInt("0b1310c5a2c30000", radix: 16)
(lldb) po w
nil

The problem seems to be with the hex strings starting with 0b.
BInt("0b", radix: 16).asString(radix: 10) also returns zero.

I bet it's thinking it's binary

https://github.com/mkrd/Swift-BigInt/blob/master/Sources/Swift-Big-Number-Core.swift#L335

Thanks for the response.
Do you consider it as a bug or it's just a normal behavior?
When I set radix: 16 then I assume that it will be treated as a hex number.

Yeah this looks like a bug.