Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想将任何双精度值转换为整数。我知道逗号后面的部分会丢失。
import java.lang.*; public int doubleToIntenger(double dbl){ int intenger; intenger = intenger.intValue(dbl); return intenger; }
但是我在编辑器中收到此错误作为工具提示:
int cannot be dereferenced
如果您只关心分数之前,只需将 double 转换为 int。 但要小心
double x = 1.999999; int val = (int)x;// val will be 1