More utility functions
parent
9dd04d2cb1
commit
83c34dbe23
13
src/bytes.jl
13
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")))
|
Loading…
Reference in New Issue