比方说有一个整型数据
int n=3;
我们用pow函数求出它的平方,此时数据类型为double
double s=Math.pow(n,2);
我们要将其转化为整型数据,则应该如下操作
int t=(new Double(s)).intValue();
有时我们要求的数据范围比较大,int不能满足,则应该转化为long类型
long x=(new Double(s)).longValue();

相关文章:

  • 2022-12-23
  • 2021-12-06
  • 2022-12-23
  • 2021-12-26
  • 2021-08-10
  • 2022-12-23
  • 2021-05-19
  • 2022-12-23
猜你喜欢
  • 2021-05-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案