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

convert(::FD{T,N}, ::Int128) and convert(::FD{T,N}, ::UInt128) allocate BigInts #83

Closed
Drvi opened this issue Nov 13, 2023 · 1 comment

Comments

@Drvi
Copy link
Collaborator

Drvi commented Nov 13, 2023

For example

julia> using FixedPointDecimals

julia> @time convert(FixedDecimal{Int,2}, Int128(1))
  0.000005 seconds (7 allocations: 128 bytes)
FixedDecimal{Int64,2}(1.00)

allocates a BigInt because a widemul is used to carry out the multiplication between the coefficient and the Int128 value during the conversion.
This is problematic performance-wise.

One workaround would be to convert the coefficient to an Int128 and then use Base.mul_with_overflow, throwing an InexactError manually on overflow.

@Drvi Drvi changed the title convert(::FD{T,N}, ::Int128) and convert(::FD{T,N}, ::Int128) allocate BigInts convert(::FD{T,N}, ::Int128) and convert(::FD{T,N}, ::UInt128) allocate BigInts Nov 13, 2023
@NHDaly
Copy link
Member

NHDaly commented Nov 21, 2023

Fixed in #84.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants