为什么 Elm 中的 "remainderBy 0 100" 0.19 return NaN,而不是 Maybe Int?

Why does "remainderBy 0 100" in Elm 0.19 return NaN, not Maybe Int?

在JavaScript中,0 % 1000,但是在Elm中,同样的操作结果是这样的。

> remainderBy 0 100
NaN : Int

我只是觉得 remainderBy 功能更好 returns Maybe Int 如下所示。

> remainderBy 0 100
Nothing : Maybe Int

> remainderBy 6 3
Just 2 : Maybe Int

Elm有什么理由remainderByreturnsNaN

remainderBy 的第一个参数是除数,与您预期的相反。所以 remainderBy 0 100100 % 0

相同

你除以 0,所以结果是 NaN。