接收 數據爲 01 03 08 42 66 66 65 47 80 6C BD AB DB
其中 42 66 66 65 爲瞬時流量 47 80 6C BD爲累計流量
通過
String hexString = " 42 66 66 65";
Float value = Float.intBitsToFloat((int)Long.parseLong(hexString.replace(" ", ""), 16));
System.out.println(value);
可計算 爲 57.599995。上面代碼 先用Long轉換 再強轉int 考慮超出 int範圍的情況。
String hexStr = Integer.toHexString(Float.floatToIntBits(value)); //hexStr ="42666665"交互轉換