package binsec
Install
Dune Dependency
Authors
-
AAdel Djoudi
-
BBenjamin Farinier
-
CChakib Foulani
-
DDorian Lesbre
-
FFrédéric Recoules
-
GGuillaume Girol
-
JJosselin Feist
-
LLesly-Ann Daniel
-
MManh-Dung Nguyen
-
MMathéo Vergnolle
-
MMathilde Ollivier
-
MMatthieu Lemerre
-
OOlivier Nicole
-
RRichard Bonichon
-
RRobin David
-
SSébastien Bardin
-
SSoline Ducousso
-
TTa Thanh Dinh
-
YYaëlle Vinçont
Maintainers
Sources
sha256=b8e7b9c756245656c481e992549fb7b1864ee6eeb492e16488e7a9d962d39cdb
sha512=07a5e4105e5275751fcc6832743f5f9eedc72bd061273ec54c4466135032852120df3784ba571656c788e5f3cd971aad8a53f030336a364e77e940e26dff38d7
doc/binsec/Binsec/Bitvector/index.html
Module Binsec.Bitvector
module type Common = sig ... end
Bitvector representation
include Common with type t := t and type boolean = bool
val size_of : t -> int
val hash : t -> int
val zero : t
val one : t
val zeros : int -> t
val ones : int -> t
val fill : ?lo:int -> ?hi:int -> int -> t
fill lo hi n
returns a bitvector of size n
where bits from lo
to hi
are set to one. By default, lo
is equal to zero and hi
is equal to n
. Raise Invalid_argument
if lo
or hi
have incoherent values.
val is_zero : t -> bool
val is_one : t -> bool
is_zero t
(resp. is_one t
) checks if t
is equal to zero
(resp. one
)
val is_zeros : t -> bool
val is_ones : t -> bool
val is_fill : t -> bool
is_zeros t
(resp. is_ones t
) checks if it exists n
such that t
is equal to zeros n
(resp. ones n
)
val max_ubv : int -> t
val max_sbv : int -> t
val min_sbv : int -> t
max_ubv n
(resp. max_sbv n
) returns a bitvector of size n
containing the biggest possible unsigned (resp. signed) value for its size
val is_max_ubv : t -> bool
val is_max_sbv : t -> bool
val is_min_sbv : t -> bool
is_max_ubv t
(resp. is_max_sbv t
) returns true
if t
is a bitvector containing the biggest possible unsigned (resp. signed) value for its size, or returns false
otherwise
include Sigs.COMPARISON
with type t := t
and type boolean = bool
with type boolean = bool
val is_neg : t -> bool
val is_pos : t -> bool
is_neg t
(resp. is_pos t
) returns true
if the signed interpretation of t
is strictly negative (resp. strictly positive)
include Sigs.BITWISE with type t := t
val num_bits : t -> int
val get_bit : t -> int -> bool
val extract : t -> int Basic_types.interval -> t
Creation functions
val rand : int -> t
rand sz
creates a bitvector of size sz with random value
val of_bool : bool -> t
val to_bool : t -> bool
val of_char : char -> t
val to_char : t -> char
val of_int32 : int32 -> t
of_int32 n
creates a bitvector of size 32 and value n
val to_int32 : t -> int32
val of_int64 : int64 -> t
of_int64 n
creates a bitvector of size 64 and value n
val to_int64 : t -> int64
val of_int : size:int -> int -> t
val to_int : t -> int
val to_uint : t -> int
val of_bits : string -> t
of_bits s
cast an ascii string s
to its bitvector representation.
val of_string : string -> t
of_string s
converts a string s
whose format respects (+-
)?0xb
0-9
+ i.e., hex and bin strings
Otherwise raises Invalid_argument
val to_string : t -> string
to_string s
converts a bitvector to hexadecimal notation (if size is a multiple of 4) or to binary (otherwise).
val of_hexstring : string -> t
of_hexstring
is an alias for of_string
val to_bitstring : t -> string
to_bitstring bv
returns the binary string representation of bv
, i.e., the string "0b"[01]+
with the same value and size as bv
.
val to_hexstring : t -> string
to_hexstring bv
returns the hex string representation of bv
, i.e., the string "0x"[0-9a-f]+
with the same value and size as bv
.
val to_asciistring : t -> string
to_asciistring bv
returns the ascii string representation of bv
.
Printing functions
val pp : Format.formatter -> t -> unit
pp ppf bv
prints the decimal value of bv
into ppf
val pp_hex : Format.formatter -> t -> unit
pp_hex ppf bv
prints the hexadecimal value of bv
into ppf
val pp_hex_or_bin : Format.formatter -> t -> unit
pp_hex ppf bv
prints the hexadecimal value of bv
into ppf
if possible, else prints the binary value of bv
.
val print : t -> string
print bv
behaves like pp Format.str_formatter bv; Format.flush_str_formatter ()
module Collection : Sigs.Collection with type t := t