Android 如何用两个小数点而不是一个零小数点显示双数值
我想显示两个小数,并以更合适的方式显示不带括号的值Android 如何用两个小数点而不是一个零小数点显示双数值,android,arrays,double,Android,Arrays,Double,我想显示两个小数,并以更合适的方式显示不带括号的值 ScanRecord scanRecord = result.getScanRecord(); assert scanRecord != null; byte[] puckData = scanRecord.getManufacturerSpecificData(0x0590); assert puckData != null; double lightValue = Double.parseDouble( A
ScanRecord scanRecord = result.getScanRecord();
assert scanRecord != null;
byte[] puckData = scanRecord.getManufacturerSpecificData(0x0590);
assert puckData != null;
double lightValue = Double.parseDouble(
Arrays.toString(new byte[]{puckData[0]}).replace("[", "").replace("]", ""));
double tempValue = Double.parseDouble(
Arrays.toString(new byte[]{puckData[1]}).replace("[", "").replace("]", ""));
double batteryValue = Double.parseDouble(
Arrays.toString(new byte[]{puckData[2]}).replace("[", "").replace("]", ""));
它将打印0.00试试这个
DecimalFormat df = new DecimalFormat(".##");
Log.d("","kilobytes (DecimalFormat) : " + df.format(123.678));
它将返回:123.68我从字节数组中得到的值是。0我该怎么做才能得到整个双精度值,然后格式化它?提前谢谢!
DecimalFormat df = new DecimalFormat(".##");
Log.d("","kilobytes (DecimalFormat) : " + df.format(123.678));