你好我對Java只有很新的感覺,只有3天了,而且我正努力爲這個程序輸出十進制數。Java靜態值不輸出小數「可能有損於從double到int的轉換」
static int temp1=66-32*(5/9);
static int temp2=95-32*(5/9);
static int temp3=85-32*(5/9);
static int temp4=65-32*(5/9);
static int temp5=(0-32)*(.55);
public static void main(String[] args) {
System.out.println("Today's temperature is 66 degrees Fahrenheit. In Celsius it is:"+temp1);
System.out.println("The temperature is 95 degress Fahrenheit in Celsius is:"+temp2);
System.out.println("The temperature is 85 degrees Fahrenheit in Celsius is:"+temp3);
System.out.println("The temperature is 65 degrees Fahrenheit in Celsius is:"+temp4);
System.out.println("The temperature is 0 degrees Fahrenheit in Celsius is:\n"+temp5);
}
雙爲您提供了最多的精度16位可能會超過小數點後16位。 –
哦,我很抱歉我的錯誤答案 – grahan
你可以更正你的答案,我會刪除我的評論。 –