看板 PLT 關於我們 聯絡資訊
(1) Rewrite the following pseudo-code if statement expression in a more realistic manner assuming that variables a and b are of type real: if (a = b) then .... (2) Explain why this is necessary. 這題好像是關於兩個實數不太可能相等的問題,但不知道該怎麼作答。 這是澳洲某大學 2006 年期末考題,請各位高手幫忙。 謝謝。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.112.16.250 ※ 編輯: trickli 來自: 59.112.16.250 (01/21 01:58)
sjgau:浮點數,千萬不要直接拿來做 相等的判斷。 02/02 21:07
sjgau:if (相對誤差of(a,b) < 1e-6) then // 視為興等 02/02 21:07