2000-02-13 08:44:06 -08:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
2011-07-27 07:17:02 -07:00
|
|
|
(* OCaml *)
|
2000-02-13 08:44:06 -08:00
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
|
|
|
(* Copyright 1996 Institut National de Recherche en Informatique et *)
|
|
|
|
(* en Automatique. All rights reserved. This file is distributed *)
|
2001-12-07 05:41:02 -08:00
|
|
|
(* under the terms of the GNU Library General Public License, with *)
|
|
|
|
(* the special exception on linking described in file ../LICENSE. *)
|
2000-02-13 08:44:06 -08:00
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(* Module [Int64]: 64-bit integers *)
|
|
|
|
|
2000-03-21 09:43:25 -08:00
|
|
|
external neg : int64 -> int64 = "%int64_neg"
|
|
|
|
external add : int64 -> int64 -> int64 = "%int64_add"
|
|
|
|
external sub : int64 -> int64 -> int64 = "%int64_sub"
|
|
|
|
external mul : int64 -> int64 -> int64 = "%int64_mul"
|
|
|
|
external div : int64 -> int64 -> int64 = "%int64_div"
|
|
|
|
external rem : int64 -> int64 -> int64 = "%int64_mod"
|
|
|
|
external logand : int64 -> int64 -> int64 = "%int64_and"
|
|
|
|
external logor : int64 -> int64 -> int64 = "%int64_or"
|
|
|
|
external logxor : int64 -> int64 -> int64 = "%int64_xor"
|
|
|
|
external shift_left : int64 -> int -> int64 = "%int64_lsl"
|
|
|
|
external shift_right : int64 -> int -> int64 = "%int64_asr"
|
|
|
|
external shift_right_logical : int64 -> int -> int64 = "%int64_lsr"
|
|
|
|
external of_int : int -> int64 = "%int64_of_int"
|
|
|
|
external to_int : int64 -> int = "%int64_to_int"
|
2015-11-03 05:08:13 -08:00
|
|
|
external of_float : float -> int64
|
|
|
|
= "caml_int64_of_float" "caml_int64_of_float_unboxed"
|
|
|
|
[@@unboxed] [@@noalloc]
|
|
|
|
external to_float : int64 -> float
|
|
|
|
= "caml_int64_to_float" "caml_int64_to_float_unboxed"
|
|
|
|
[@@unboxed] [@@noalloc]
|
2000-03-21 09:43:25 -08:00
|
|
|
external of_int32 : int32 -> int64 = "%int64_of_int32"
|
|
|
|
external to_int32 : int64 -> int32 = "%int64_to_int32"
|
|
|
|
external of_nativeint : nativeint -> int64 = "%int64_of_nativeint"
|
|
|
|
external to_nativeint : int64 -> nativeint = "%int64_to_nativeint"
|
2000-02-13 08:44:06 -08:00
|
|
|
|
2003-04-25 05:27:31 -07:00
|
|
|
let zero = 0L
|
|
|
|
let one = 1L
|
|
|
|
let minus_one = -1L
|
|
|
|
let succ n = add n 1L
|
|
|
|
let pred n = sub n 1L
|
|
|
|
let abs n = if n >= 0L then n else neg n
|
|
|
|
let min_int = 0x8000000000000000L
|
|
|
|
let max_int = 0x7FFFFFFFFFFFFFFFL
|
|
|
|
let lognot n = logxor n (-1L)
|
2000-02-13 08:44:06 -08:00
|
|
|
|
2004-01-01 08:42:43 -08:00
|
|
|
external format : string -> int64 -> string = "caml_int64_format"
|
2000-02-13 08:44:06 -08:00
|
|
|
let to_string n = format "%d" n
|
|
|
|
|
2004-01-01 08:42:43 -08:00
|
|
|
external of_string : string -> int64 = "caml_int64_of_string"
|
2001-02-05 00:54:18 -08:00
|
|
|
|
2015-11-03 05:08:13 -08:00
|
|
|
external bits_of_float : float -> int64
|
|
|
|
= "caml_int64_bits_of_float" "caml_int64_bits_of_float_unboxed"
|
|
|
|
[@@unboxed] [@@noalloc]
|
|
|
|
external float_of_bits : int64 -> float
|
|
|
|
= "caml_int64_float_of_bits" "caml_int64_float_of_bits_unboxed"
|
|
|
|
[@@unboxed] [@@noalloc]
|
2002-06-26 02:13:59 -07:00
|
|
|
|
|
|
|
type t = int64
|
|
|
|
|
2007-01-30 01:34:36 -08:00
|
|
|
let compare (x: t) (y: t) = Pervasives.compare x y
|
2014-12-21 03:46:08 -08:00
|
|
|
let equal (x: t) (y: t) = compare x y = 0
|