作者speed73131.bbs@ptt.cc (冰逸) 看板: linux
標題Re: 奇怪的程式結果
時間批踢踢實業 (2008/03/17 Mon 17:51:51)
※ 引述《coscell.bbs@bbs.cis.nctu.edu.tw (goodman)》之銘言:
: 請教各位前輩下面這段程式:
: #include <stdio.h>
: int main()
: {
: long int salary=10800000;
: float tax=0.48;
: printf("年薪:\t%ld\n",salary);
: printf("稅額:\t%f\n",salary*tax);
: return 0;
: }
: 執行結果:
: 年薪: 10800000
: 稅額: 5183999.884129
: 請問為什麼會這樣?哪裡錯了?感謝指教!
用JAVA寫的???????????
假如是的話
public class test {
public static void main(String[] args) {
long salary=10800000;
float tax=0.48f;
System.out.printf("年薪:%d\n",salary);
System.out.printf("稅額:%f\n",tax*salary);
}
}
X
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.116.31.17
推 Adama:會猜java會不會跳太遠了點... show off? XD 03/17 17:51