zoukankan      html  css  js  c++  java
  • byte最高位

    /**
    * 将byte转换为一个长度为8的byte数组,数组每个值代表bit
    */
    public static byte[] replaceSpace(Byte b){
    byte[] array=new byte[8];
    for (int i = 7; i >=0 ; i--) {
    //& 运算规则:两个数都转为二进制,然后从高位开始比较,如果两个数都为1则为1,否则为0。
    array[i]=(byte) (b & 1);
    //右移一位 b/2
    b=(byte)(b >>1);
    }
    return array;
    }

    public static String byteToBit(byte b){
        return ""
    + (byte) ((b >> 7) & 1) + (byte) ((b >> 6) & 1)
    + (byte) ((b >> 5) & 1) + (byte) ((b >> 4) & 1)
    + (byte) ((b >> 3) & 1) + (byte) ((b >> 2) & 1)
    + (byte) ((b >> 1) & 1) + (byte) ((b >> 0) & 1);
    }
    /**
    * byte最高位
    */
    public static String max(Byte b){
        return ""
    +(byte) ((b >> 7) & 1);
    }
  • 相关阅读:
    keras_12_keras自带的Applications
    keras_11_keras中示例数据集
    keras_10_回调函数 Callbacks
    Runloop
    SDWebImage
    NSOperation
    单例模式
    GCD
    一文读懂汉明码
    聊聊SPOOLing技术
  • 原文地址:https://www.cnblogs.com/sun27/p/13389642.html
Copyright © 2011-2022 走看看