为什么命令提示符和计算器给出不同的答案?

Why Command Prompt and calculator gives different answer?

enter image description here我正在学习这些算术运算以及如何使用记事本和命令提示符,并在我的 phone 计算器和笔记本电脑计算器上检查它们是否正确,它给出了不同的答案。我正在使用 java 语言

我试过手动计算

整数 x =12; 浮动 y = 13.54f;

System.out.println(x/y+"devide 12 - 13.54");//0.88691795 在我的计算中我得到 0.886262924667...

TL;DR: 无法重现。

来自问题:

I've tried computing it manually

Int x =12; float y = 13.54f;

System.out.println(x/y+" devide 12 - 13.54");//0.88691795 on my calcu i get 0.886262924667...

我不知道你从哪里得到0.88691795
当我 运行 你的代码时,我得到 0.88626295

这是您的代码的扩展版本,输出为:

int x = 12;
float y = 13.54f;
double z = 13.54;
System.out.println(x/y + "         using float math");
System.out.println(x/z + " using double math");
System.out.println("0.886262924667...  using calcu");
0.88626295         using float math
0.8862629246676514 using double math
0.886262924667...  using calcu

如您所见,其中 none 给出了您声称获得的结果。请重试。