gpt4 book ai didi

java - 如何在点后将 double 转换为 2 数?

转载 作者:IT老高 更新时间:2023-10-28 23:26:25 24 4
gpt4 key购买 nike

Possible Duplicate:
Round a double to 2 significant figures after decimal point

如何将点后的 double 转换为 2 数?

例如:

double x=123.45678;

我需要那个x=123.45(在java for android中)

提前致谢

最佳答案

x = Math.floor(x * 100) / 100;

关于java - 如何在点后将 double 转换为 2 数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7415733/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com