You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
, test "logBase 10 100"<|\()->Expect.equal 2(logBase 10100)
As above, a unit test exists checking logBase 10 100, however if this had checked logBase 10 1000, it would have caught the fact that logBase 10 x implemented as log x / log 10 (using JavaScript's natural logarithm) can yield results slightly less than an integer even for small power of 10 inputs. This unfortunately complicates a common use case for logBase 10: finding it's floor in order to determine a exponent when formatting a number in scientific notation.
JavaScript's log10 is provided separately specifically to address this imprecision, and indeed it returns an integer for all powers of 10 ranging from -311 to 308 (i.e., all those representable as normal IEEE 754 binary64 floats and even a few of the subnormals). Accordingly, I respectfully recommend either adding a corresponding log10 function in Elm or a special case for logBase 10 that instead calls JavaScript's log10.
The text was updated successfully, but these errors were encountered:
core/tests/tests/Test/Basics.elm
Line 136 in e2b18de
As above, a unit test exists checking
logBase 10 100
, however if this had checkedlogBase 10 1000
, it would have caught the fact thatlogBase 10 x
implemented as log x / log 10 (using JavaScript's natural logarithm) can yield results slightly less than an integer even for small power of 10 inputs. This unfortunately complicates a common use case forlogBase 10
: finding it'sfloor
in order to determine a exponent when formatting a number in scientific notation.JavaScript's
log10
is provided separately specifically to address this imprecision, and indeed it returns an integer for all powers of 10 ranging from -311 to 308 (i.e., all those representable as normal IEEE 754 binary64 floats and even a few of the subnormals). Accordingly, I respectfully recommend either adding a correspondinglog10
function in Elm or a special case forlogBase 10
that instead calls JavaScript'slog10
.The text was updated successfully, but these errors were encountered: