Evaluating
bitstring(Int8(3))
returns "00000011". Is there an in-built function in Julia to do the inverse operation of parsing a bitstring to an integer?
Evaluating
bitstring(Int8(3))
returns "00000011". Is there an in-built function in Julia to do the inverse operation of parsing a bitstring to an integer?
The method parse(::Type{T}, s::AbstractString; kwargs...) takes base as one of the keyword arguments. See: https://github.com/JuliaLang/julia/blob/539f3ce943f59dec8aff3f2238b083f1b27f41e5/base/parse.jl#L376 and https://github.com/JuliaLang/julia/blob/539f3ce943f59dec8aff3f2238b083f1b27f41e5/base/parse.jl#L92.
So, you can do:
parse(Int8, bitstring(Int8(3)), base=2)
and it correctly returns 3.