summaryrefslogtreecommitdiff
path: root/stdlib/int32.ml
diff options
context:
space:
mode:
authorAlain Frisch <alain@frisch.fr>2021-05-11 21:24:29 +0200
committerGitHub <noreply@github.com>2021-05-11 21:24:29 +0200
commit79f6c2228b4a30d472472f3160148ba600fb67d0 (patch)
tree844a5d353c7c85b28278872cec17a20b99563264 /stdlib/int32.ml
parentea2b165323657177bb5e3c162098fcf2ec0769e2 (diff)
downloadocaml-79f6c2228b4a30d472472f3160148ba600fb67d0.tar.gz
Add {Int,Int32,Int64,NativeInt}.{min,max} (#10392)
Diffstat (limited to 'stdlib/int32.ml')
-rw-r--r--stdlib/int32.ml3
1 files changed, 3 insertions, 0 deletions
diff --git a/stdlib/int32.ml b/stdlib/int32.ml
index 79864d6d3d..a51e2f9c82 100644
--- a/stdlib/int32.ml
+++ b/stdlib/int32.ml
@@ -86,6 +86,9 @@ let equal (x: t) (y: t) = compare x y = 0
let unsigned_compare n m =
compare (sub n min_int) (sub m min_int)
+let min x y : t = if x <= y then x else y
+let max x y : t = if x >= y then x else y
+
(* Unsigned division from signed division of the same
bitness. See Warren Jr., Henry S. (2013). Hacker's Delight (2 ed.), Sec 9-3.
*)