More utility functions

main
Jacob Windle 2023-04-21 07:14:40 -04:00
parent 9dd04d2cb1
commit 83c34dbe23
1 changed files with 13 additions and 0 deletions

View File

@ -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")))