Reorganize src/ directory
This commit is contained in:
parent
8aa8b9b69a
commit
3c0c2cff6f
19 changed files with 12 additions and 5 deletions
20
src/core/bit.ml
Normal file
20
src/core/bit.ml
Normal file
|
@ -0,0 +1,20 @@
|
|||
(**
|
||||
* Copyright (c) 2015, Fabien Freling
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD 2-clause license found in the
|
||||
* LICENSE file at the top level directory of this source tree.
|
||||
*)
|
||||
|
||||
let is_set num i =
|
||||
if i < 0 then
|
||||
failwith "Invalid bit index."
|
||||
else
|
||||
(num lsr i) land 0b00000001 <> 0
|
||||
|
||||
let two_complement n =
|
||||
(lnot n) + 1
|
||||
|
||||
let signed_byte n =
|
||||
if n land 0x80 <> 0 then -((two_complement n) land 0xFF)
|
||||
else n
|
Loading…
Add table
Add a link
Reference in a new issue