Fix: calculate log10 for a bigint with value zero (fixes #3539)#3555
Fix: calculate log10 for a bigint with value zero (fixes #3539)#3555
log10 for a bigint with value zero (fixes #3539)#3555Conversation
Yes I think there's no reason to go to Complex for the particular case of 0n. Since it returns number for positive bigint, the number -Infinity would make more sense. I guess that needs to be special-cased in promoteLogarithm... |
… the log functions.
|
Ok we can change that. And of course for negative values we still evaluate to a complex result. With the latest update in this PR, the behavior is now as follows, and I think that's OK:
|
|
Oops, I have now lost the thread of why when predictable is true, the log10(0n) should switch from -Infinity to NaN? "Predictable: true" means that the type of the output should be determined by the type of the input, with no dependence on the value of the input. The "predictable" signature for log10 on a bigint is to return an (ordinary JavaScript) What does seem correct is that for negative arguments, when predictable is true, log10 of a bigint should return NaN, since there is no |
Addresses the first case of
log10(0n)in #3539.We may want to think through the behavior for all numeric types. Current behavior (with this bugfix applied):
predictable:falsepredictable:truemath.log10(0)-Infinity-Infinitymath.log10(math.bignumber('0'))bignumber('-Infinity')bignumber('-Infinity')math.log10(0n)complex(Infinity, Infinity)NaNmath.log10(false)-Infinity-InfinityFor consistency, it may be better to return
complex(Infinity, Infinity)for every data type. Or the other way around:return
-Infinityin case of a bigint (depending on the configurednumberFallback).Any thoughs on this @gwhitney?