[問題] int計算錯誤
一個double precision的運算式中print出來的值是-119.000000000000
但若取int卻print出現-118,這當中出現了什麼問題呢?
程式碼大約如下:
double precision x,y
.
.
.
.
.
.
.
.
print*,(x-y)*10.0d+00, int((x-y)*10.0d+00)
結果:
-115.000000000000 -115
-116.000000000000 -116
-117.000000000000 -117
-118.000000000000 -118
-119.000000000000 -118
恩...我無言了...= =''
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 115.43.222.152
※ 文章網址: https://www.ptt.cc/bbs/Fortran/M.1442169276.A.9A3.html
→
09/14 09:56, , 1F
09/14 09:56, 1F
→
09/14 10:58, , 2F
09/14 10:58, 2F
→
09/14 11:02, , 3F
09/14 11:02, 3F
→
09/14 13:22, , 4F
09/14 13:22, 4F
→
09/14 13:42, , 5F
09/14 13:42, 5F
→
09/14 13:42, , 6F
09/14 13:42, 6F
→
09/14 13:44, , 7F
09/14 13:44, 7F
→
09/14 13:46, , 8F
09/14 13:46, 8F
→
09/14 13:56, , 9F
09/14 13:56, 9F
→
09/14 14:02, , 10F
09/14 14:02, 10F
→
09/14 14:04, , 11F
09/14 14:04, 11F
→
09/14 14:13, , 12F
09/14 14:13, 12F
→
09/14 14:13, , 13F
09/14 14:13, 13F
→
09/14 14:15, , 14F
09/14 14:15, 14F
→
09/14 14:15, , 15F
09/14 14:15, 15F
→
09/14 14:16, , 16F
09/14 14:16, 16F
→
09/14 14:18, , 17F
09/14 14:18, 17F
→
09/14 14:26, , 18F
09/14 14:26, 18F
→
09/14 14:27, , 19F
09/14 14:27, 19F
→
09/14 22:02, , 20F
09/14 22:02, 20F
Fortran 近期熱門文章
PTT數位生活區 即時熱門文章