Java: Convert scientific notation to regular int

前端 未结 6 433
迷失自我
迷失自我 2020-12-06 10:23

How do I convert scientific notation to regular int For example: 1.23E2 I would like to convert it to 123

Thanks.

6条回答
  •  旧巷少年郎
    2020-12-06 10:45

    You can just cast it to int as:

    double d = 1.23E2; // or float d = 1.23E2f;
    int i = (int)d; // i is now 123
    

提交回复
热议问题