Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for JSON_TYPE_INT type when numbers above 2^64-1 are passed #145

Merged
merged 2 commits into from Sep 9, 2019

Conversation

pali
Copy link
Contributor

@pali pali commented Aug 22, 2019

  • allow to encode numeric values above 2^64 in PV slot
  • allow to pass Math::BigInt and Math::BigFloat objects

…t via Math::BigInt/Float

Option ->allow_bignum is required for it as big number is parsed via
Math::BigInt or Math::BigFloat (based on what grok_number returns) as it
cannot be represented in UV type.
…at objects

Option ->allow_bignum is required. Without it it is not possible to pass
Math::BigInt and Math::BigFloat objects.

For converting Math::BigFloat to Math::BigInt should be used $obj->bint
method, equivalent of perl's int() function for non-big floats. But this
method is not available in older Math::BigFloat versions. Older
Math::BigFloat versions have $obj->as_number method which should do same
thing as $obj->bint method but in some Math::BigFloat versions it is broken
and loose precision, so it cannot be used.

So for conversion from Math::BigFloat to Math::BigInt use either
$obj->bceil or $obj->bfloor method based on information if $obj is negative
or not. This is simulation of rounding and should give us same result as
$obj->bint method.
@coveralls
Copy link

coveralls commented Aug 22, 2019

Coverage Status

Coverage remained the same at 87.64% when pulling 28b6e20 on pali:master into 5a11a26 on rurban:master.

@rurban
Copy link
Owner

rurban commented Aug 22, 2019

Nice!

@rurban rurban self-assigned this Sep 9, 2019
@rurban rurban self-requested a review September 9, 2019 14:46
@rurban rurban merged commit 28b6e20 into rurban:master Sep 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants