【MapSheep】
[好记性不如烂笔头]

示例代码

public class Company {
    public static void main(String[] args) {


        // 示例, 支持0.2开头
        String currentVoltage = "20.014";

        // 转换双精度
        int totalFee1 = (int) (Double.parseDouble(currentVoltage));

        // 转换单精度, 有时会使数据值变小;
        int totalFee2 = (int) (Float.parseFloat(currentVoltage));

        // 输出 20 20
        System.out.println("totalFee1:" + totalFee1 + ",totalFee2:" + totalFee2 + ".");
        
    }
}
posted on 2021-02-20 16:30  (Play)  阅读(2695)  评论(0编辑  收藏  举报