1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798(*
* BatNativeInt - Extended native ints
* Copyright (C) 2005 Damien Doligez
* 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
*)moduleBaseNativeint=structincludeNativeintletmodulo=remletpow=BatNumber.generic_pow~zero~one~div_two:(funn->shift_rightn1)~mod_two:(logandone)~mulendincludeBatNumber.MakeNumeric(BaseNativeint)letmin_int=Nativeint.min_intletmax_int=Nativeint.max_intletminus_one=Nativeint.minus_oneletlognot=Nativeint.lognotletsize =Nativeint.sizeexternalneg:nativeint->nativeint="%nativeint_neg"externaladd:nativeint->nativeint->nativeint="%nativeint_add"externalsub:nativeint->nativeint->nativeint="%nativeint_sub"externalmul:nativeint->nativeint->nativeint="%nativeint_mul"externaldiv:nativeint->nativeint->nativeint="%nativeint_div"externalrem:nativeint->nativeint->nativeint="%nativeint_mod"externallogand:nativeint->nativeint->nativeint="%nativeint_and"externallogor:nativeint->nativeint->nativeint="%nativeint_or"externallogxor:nativeint ->nativeint->nativeint="%nativeint_xor"externalshift_left:nativeint ->int->nativeint="%nativeint_lsl"externalshift_right:nativeint ->int->nativeint="%nativeint_asr"externalshift_right_logical :nativeint->int->nativeint="%nativeint_lsr"externalof_int:int->nativeint="%nativeint_of_int"externalto_int:nativeint->int="%nativeint_to_int"externalof_float:float->nativeint="caml_nativeint_of_float"##V>=4.3##"caml_nativeint_of_float_unboxed"[@@unboxed][@@noalloc]externalto_float :nativeint->float="caml_nativeint_to_float"##V>=4.3##"caml_nativeint_to_float_unboxed"[@@unboxed][@@noalloc]external of_int32:int32->nativeint ="%nativeint_of_int32"external to_int32:nativeint->int32="%nativeint_to_int32"external of_int64:int64->nativeint ="%int64_to_nativeint"external to_int64:nativeint->int64="%int64_of_nativeint"(*$T of_int32
(of_int32 8l) = 8n
*)(*$T to_int32
(to_int32 8n) = 8l
*)(*$T of_int64
(of_int64 9L) = 9n
*)(*$T to_int64
(to_int64 9n) = 9L
*)externalof_string:string->nativeint ="caml_nativeint_of_string"##V>=4.5##letof_string_opt =Nativeint.of_string_opt##V<4.5##letof_string_opts=trySome(Nativeint.of_strings)with_->Noneexternalformat:string->nativeint->string="caml_nativeint_format"##V>=4.08##let unsigned_compare=Nativeint.unsigned_compare##V>=4.08##letunsigned_to_int =Nativeint.unsigned_to_int##V>=4.08##letunsigned_rem =Nativeint.unsigned_rem##V>=4.08##letunsigned_div =Nativeint.unsigned_div##V>=5.1##letseeded_hash=Nativeint.seeded_hash##V>=5.1##lethash=Nativeint.hashtypebounded=tletmin_num,max_num=min_int,max_intletprintoutt=BatPrintf.fprintfout"%nx"tlett_printer_parenoutt=printouttletmin(x:t)(y:t):t=ifx<=ythenxelseyletmax(x:t)(y:t):t=ifx>=ythenxelsey