How to get the full fraction value of a division result in java? [duplicate]

五迷三道 提交于 2019-12-01 14:23:11

Try, this instead:

double t = 49700/40000.0;
System.out.println(t);

If both operands are integers the result will be an integer which will be truncated, and then it will be cast in to a double. If, instead, one of the operands is a double, the result will be a double.

Use float for decimal number computations

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!