1234567891011121314151617181920212223242526272829303132333435363738(**********************************************************************)(* *)(* This file is part of the RFSM package *)(* *)(* Copyright (c) 2018-present, Jocelyn SEROT. All rights reserved. *)(* *)(* This source code is licensed under the license found in the *)(* LICENSE file in the root directory of this source tree. *)(* *)(**********************************************************************)(**{1 Bit-level manipulation of integers} *)letof_uintsn=letb=Bytes.makes'0'inletrechni=ifi>=0thenbeginBytes.setbi(ifnmod2=1then'1'else'0');h(n/2)(i-1)endinhn(s-1);Bytes.to_stringbletcpl2nx=Ext.Base.pow2n-xletof_intsv=ifv<0thenof_uints(cpl2s(-v))elseof_uintsvletget_bits~hi~lon=(nlsrlo)mod(1lsl(hi-lo+1))letset_bits~hi~lo~dstv=letv'=vmod(1lsl(hi-lo+1))inletmsk=letr=ref0infori=lotohidor:=!rlor(1lsli)done;!rin(dstland(lnotmsk))lor(v'lsllo)letrecbit_sizen=ifn=0then0else1+bit_size(n/2)