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
I'm wondering if switching the int repr in jaq-json to i64 would be a viable option (I saw the comment that isize allows ints to easily index arrays, but it seems the trade-off isn't as good if int is also comprehensively tested against arithmetic operations)
I have thought for some time about this suggestion. I think that rather than changing Int(isize) to Int(i64) in jaq_json::Val, it would be a nicer solution to support BigInt as an additional type of values BigInt(BigInt) (next to Int(isize)). That way, we could handle integers of any size on any architecture, switching automatically from isize to BigInt when the result of an operation exceeds isize.
I was worried that rounding from f64 might be an issue, but I think that this works nicely: When we have a f: f64, we can convert it to an integer representation via format!("{:.0}", f), and from there, we can simply parse() it to a BigInt. We just have to be careful when f is NaN or infinity, in which case we should probably return f unchanged. (This is currently not handled correctly by jaq.)
This work would mostly involve modifying jaq-json (and slightly jaq-std), I believe, and does not touch jaq-core. Therefore, it would be a good first issue for someone who is motivated to implement this.
The text was updated successfully, but these errors were encountered:
In #243, @tranzystorekk made the following comment:
I have thought for some time about this suggestion. I think that rather than changing
Int(isize)
toInt(i64)
injaq_json::Val
, it would be a nicer solution to supportBigInt
as an additional type of valuesBigInt(BigInt)
(next toInt(isize)
). That way, we could handle integers of any size on any architecture, switching automatically fromisize
toBigInt
when the result of an operation exceedsisize
.I was worried that rounding from
f64
might be an issue, but I think that this works nicely: When we have af: f64
, we can convert it to an integer representation viaformat!("{:.0}", f)
, and from there, we can simplyparse()
it to aBigInt
. We just have to be careful whenf
is NaN or infinity, in which case we should probably returnf
unchanged. (This is currently not handled correctly by jaq.)This work would mostly involve modifying
jaq-json
(and slightlyjaq-std
), I believe, and does not touchjaq-core
. Therefore, it would be a good first issue for someone who is motivated to implement this.The text was updated successfully, but these errors were encountered: