diff --git a/src/bytes.jl b/src/bytes.jl index e4d3baa..95073aa 100644 --- a/src/bytes.jl +++ b/src/bytes.jl @@ -1,3 +1,6 @@ +module bytes + +export byte_vec_to_int, byte_vec_to_string, bit_at """ read_data_size(size::Vector{UInt8})::Real @@ -23,4 +26,14 @@ function byte_vec_to_string(byte_vec::Vector{UInt8})::AbstractString String(Char.(byte_vec)) end +""" + bit_at(byte::UInt8, idx::Int64; t::Type=Int64)::Int64 + +Parse the bit at specific index in byte +""" +function bit_at(byte::UInt8, idx::Int64; t::Type=Int64)::Int64 + parse(t, bitstring(byte)[idx]) +end + +end # byte_vec_to_string(UInt8.(collect("ABC"))) \ No newline at end of file