summaryrefslogtreecommitdiffstats
path: root/utils/nativeint.ml
diff options
context:
space:
mode:
Diffstat (limited to 'utils/nativeint.ml')
-rw-r--r--utils/nativeint.ml9
1 files changed, 9 insertions, 0 deletions
diff --git a/utils/nativeint.ml b/utils/nativeint.ml
index 6332b7b24..43a7f6904 100644
--- a/utils/nativeint.ml
+++ b/utils/nativeint.ml
@@ -52,3 +52,12 @@ let to_string n =
(if n.msw >= 0 then "" else "-") ^
(if q > 0 then string_of_int q else "") ^
string_of_int (r * 2 + a.lsb)
+
+let to_hexa_string n =
+ let a = if n.msw >= 0 then n else sub (from 0) n in
+ let q = a.msw lsr 3 in
+ let r = a.msw land 0x7 in
+ Printf.sprintf "%s0x%x%x"
+ (if n.msw >= 0 then "" else "-")
+ q
+ (r * 2 + a.lsb)