zoukankan      html  css  js  c++  java
  • 位运算Pascal相关函数/过程

    Function Getlen(P:longint):longint;
    var
     i:longint;
      begin
      getlen:=0;
      for i:=1 to 31 do
        begin
        if p and 1=1 then getlen:=i;
        p:=p shr 1;
      end;
    end;
    
    Function GetBit(Num,bit:longint):boolean;
      begin
      if (num and (1 shl(bit-1)))=0 then exit(false) else exit(true);
    end;
    
    Procedure changeBit(var num:longint;bit:longint;opt:boolean);
      begin
      if opt then
        num:=num or (1 shl (bit-1))
      else
        num:=num and not (1 shl (bit-1));
    end;
    
    Function getblock(num:longint;start,len:longint):longint;
    var
     i,tmp:longint;
      begin
      tmp:=0;
      for i:=1 to len do
        tmp:=tmp or (1 shl (i-1));
      Getblock:=(num and (tmp shl (start-1))) shr (start-1);
    end;
    
    Procedure changeBlock(var num:longint;start,opt:longint);
    var
     len,tmp,i:longint;
      begin
      len:=getlen(opt);
      tmp:=0;
      for i:=1 to len do
        begin
        tmp:=tmp or 1;
        tmp:=tmp shl 1;
      end;
      tmp:=not (tmp shl (start-1));
      num:=num and tmp;
      num:=num or (opt shl (start-1));
    end;      
    
  • 相关阅读:
    vue
    生成数组方式
    绕过CDN查找真实IP方法
    SQL注入WAF绕过
    缓冲区溢出的保护机制
    Redis未授权漏洞
    AFL 漏洞挖掘
    python多线程与多进程
    Java8四大核心接口示例
    @Autowired抱空指针异常解决方案
  • 原文地址:https://www.cnblogs.com/htfy/p/2412251.html
Copyright © 2011-2022 走看看