我正在尝试将单元格值设置为一个不错的float
值。我想将单元格值设置为5.2
,但我得到5.1999998093
了。对此有什么解决方案?
Workbook workbook = new HSSFWorkbook();
Sheet worksheet = workbook.createSheet();
CellStyle style = workbook.createCellStyle();
style.setDataFormat(HSSFDataFormat.getBuiltinFormat("0.0"));
int i = 0;
worksheet.createRow(i + 1);
worksheet.getRow(i + 1).createCell(0).setCellStyle(style);
worksheet.getRow(i + 1).getCell(0).setCellValue(new BigDecimal("5.2").floatValue());