12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182(*
* BatInt64 - Extended 64-bit integers
* Copyright (C) 2007 Bluestorm <bluestorm dot dylc on-the-server gmail dot com>
* 2008 David Teller
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version,
* with the special exception on linking described in file LICENSE.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*)moduleBaseInt64=structincludeInt64letmodulo=remletpow=BatNumber.generic_pow~zero~one~div_two:(funn->shift_rightn1)~mod_two:(logandone)~mulendincludeBatNumber.MakeNumeric(BaseInt64)letmin_int =Int64.min_intletmax_int=Int64.max_intletminus_one=Int64.minus_oneletlognot=Int64.lognotexternalneg:int64->int64="%int64_neg"externaladd:int64->int64->int64="%int64_add"externalsub:int64->int64->int64="%int64_sub"externalmul:int64->int64->int64="%int64_mul"externaldiv:int64->int64->int64="%int64_div"externalrem:int64->int64->int64="%int64_mod"externallogand:int64->int64->int64="%int64_and"externallogor:int64->int64->int64="%int64_or"externallogxor:int64 ->int64->int64="%int64_xor"externalshift_left:int64->int->int64="%int64_lsl"externalshift_right:int64->int->int64="%int64_asr"externalshift_right_logical :int64->int->int64="%int64_lsr"externalof_int:int->int64="%int64_of_int"externalto_int:int64 ->int="%int64_to_int"externalof_float:float ->int64="caml_int64_of_float"##V>=4.3##"caml_int64_of_float_unboxed"[@@unboxed][@@noalloc]externalto_float :int64->float="caml_int64_to_float"##V>=4.3##"caml_int64_to_float_unboxed"[@@unboxed][@@noalloc]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"external of_string:string->int64="caml_int64_of_string"##V>=4.5##letof_string_opt=Int64.of_string_opt##V<4.5##letof_string_optn=trySome(Int64.of_stringn)with_->Noneexternalbits_of_float:float->int64="caml_int64_bits_of_float"##V>=4.3##"caml_int64_bits_of_float_unboxed"[@@unboxed][@@noalloc]externalfloat_of_bits:int64->float="caml_int64_float_of_bits"##V>=4.3##"caml_int64_float_of_bits_unboxed" [@@unboxed][@@noalloc]external format:string->int64->string="caml_int64_format"##V>=4.08##letunsigned_compare =Int64.unsigned_compare##V>=4.08##letunsigned_to_int=Int64.unsigned_to_int##V>=4.08##letunsigned_rem=Int64.unsigned_rem##V>=4.08##letunsigned_div =Int64.unsigned_divletprintoutt=BatInnerIO.nwriteout(to_stringt)letprint_hexoutt=BatPrintf.fprintfout"%Lx"tletmin(x:t)(y:t):t=ifx<=ythen xelseyletmax(x:t)(y:t):t=ifx>=ythenxelsey##V>=5.1##letseeded_hash=Int64.seeded_hash##V>=5.1##lethash=Int64.hash