public static float to(byte b,byte a){ return (float) (((((short)b) << 8) | a & 0xff) / 32768.00 * 16.00); } 使用kotlin重写
时间: 2024-05-19 16:14:37 浏览: 117
java对象转成byte数组的3种方法
& 0xFF) / 32768.0);
}
This method takes in two bytes (b and a) and returns a float value. It first shifts the value of b to the left by 8 bits and then bitwise ORs it with the value of a, masking it with 0xFF to ensure that only the least significant 8 bits are used. The resulting value is then divided by 32768.0 to convert it to a float between -1.0 and 1.0. This method is commonly used to convert two bytes representing a 16-bit signed integer (in two's complement form) into a float value.
阅读全文