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
Describe the bug
A bigint value is rejected as an Array or Matrix index in mathjs expressions. This ban is particularly onerous when the number default is bigint.
To Reproduce
const math = create(all, {number: 'bigint'}
console.log(math.evaluate('[4,5,6][2]')
Rather than logging 5n, this throws an error with message TypeError: Dimension must be an Array, Matrix, number, string, or Range
Discussion
While I understand that JavaScript does not allow bigint array indices, the mathjs expression language aspires to mathematical accuracy and logic. From such a perspective, there is no reason to disparage bigint indices; in fact, they are in some sense more natural, as array/matrix indices must be integers, and bigints only represent integers. Furthermore, when doing high-precision integer arithmetic, the {number: 'bigint'} configuration is very useful, but it is currently practically very cumbersome to use because of the need to convert indices to number explicitly.
Recommendation
Indexing with bigints be supported. Unless there is any objection, I will develop a PR to this effect.
The text was updated successfully, but these errors were encountered:
Describe the bug
A bigint value is rejected as an Array or Matrix index in mathjs expressions. This ban is particularly onerous when the number default is bigint.
To Reproduce
Rather than logging
5n
, this throws an error with messageTypeError: Dimension must be an Array, Matrix, number, string, or Range
Discussion
While I understand that JavaScript does not allow bigint array indices, the mathjs expression language aspires to mathematical accuracy and logic. From such a perspective, there is no reason to disparage bigint indices; in fact, they are in some sense more natural, as array/matrix indices must be integers, and bigints only represent integers. Furthermore, when doing high-precision integer arithmetic, the
{number: 'bigint'}
configuration is very useful, but it is currently practically very cumbersome to use because of the need to convert indices to number explicitly.Recommendation
Indexing with bigints be supported. Unless there is any objection, I will develop a PR to this effect.
The text was updated successfully, but these errors were encountered: