当我正在制作自己的计算器时,我遇到的问题是我的双数据类型以未知格式转换我的答案,这是我的示例代码
class Myclass
{
public static void main(String args[])
{
Double d = 0.0000001 * 1;
System.out.println("D = "+d);
[1]}
}
please check the image for the output
如何解决这类问题?
答案 0 :(得分:1)
这不是问题。它是输出。 1e-7
是指1x(10^-7)
或一乘以十次幂减去七。
答案 1 :(得分:1)
System.out.printf("%f%n", d);
,其中%f表示浮点数(在您的情况下为double),%n仅表示新行。
请查看the java docs了解更多详情