diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 1997-07-30 01:12:38 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 1997-07-30 01:12:38 +0000 |
commit | d94d8a8f40b4f5295672be3c197d327ebd9137cf (patch) | |
tree | b0df7d9398111fc39c01d3eb71717abe2948fc6e | |
parent | 64d8dd8c428f29915cc3496f55a34f86d59e560c (diff) |
Ajout de to_hexa_string pour gas/Alpha
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1673 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | utils/nativeint.ml | 9 | ||||
-rw-r--r-- | utils/nativeint.mli | 3 |
2 files changed, 12 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) diff --git a/utils/nativeint.mli b/utils/nativeint.mli index 5063c6f87..76ea7de83 100644 --- a/utils/nativeint.mli +++ b/utils/nativeint.mli @@ -38,3 +38,6 @@ val cmp: t -> int -> int (* [cmp n1 i2] is [compare n1 (from i2)]. *) val to_string: t -> string (* Return the signed decimal representation of a native integer. *) +val to_hexa_string: t -> string + (* Return the signed hexadecimal representation of a native integer, + in 0x notation. *) |