More utility functions
This commit is contained in:
@@ -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")))
|
||||
Reference in New Issue
Block a user