Skip to content

Commit

Permalink
Implement Nat.length_nat as an external primitive
Browse files Browse the repository at this point in the history
  • Loading branch information
vouillon committed Oct 25, 2023
1 parent f90804a commit ac23ba3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/nat.ml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ external lxor_digit_nat: nat -> int -> nat -> int -> unit = "lxor_digit_nat"
external initialize_nat: unit -> unit = "initialize_nat"
let _ = initialize_nat()

let length_nat (n : nat) = Obj.size (Obj.repr n) - 1
external length_nat : nat -> int = "length_nat"

let length_of_digit = Sys.word_size;;

Expand Down
2 changes: 1 addition & 1 deletion src/nat.mli
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ external nth_digit_nat: nat -> int -> int = "nth_digit_nat"
external set_digit_nat_native: nat -> int -> nativeint -> unit
= "set_digit_nat_native"
external nth_digit_nat_native: nat -> int -> nativeint = "nth_digit_nat_native"
val length_nat : nat -> int
external length_nat : nat -> int = "length_nat"
external num_digits_nat: nat -> int -> int -> int = "num_digits_nat"
external num_leading_zero_bits_in_digit: nat -> int -> int
= "num_leading_zero_bits_in_digit"
Expand Down

0 comments on commit ac23ba3

Please sign in to comment.