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

bug: weird issues with big MultiFloats #38

Closed
nsajko opened this issue Dec 24, 2022 · 1 comment
Closed

bug: weird issues with big MultiFloats #38

nsajko opened this issue Dec 24, 2022 · 1 comment

Comments

@nsajko
Copy link
Contributor

nsajko commented Dec 24, 2022

julia> using MultiFloats

julia> MultiFloats.use_standard_multifloat_arithmetic(20)

julia> g(n::Integer) = rand(MultiFloat{Float64, n})
g (generic function with 1 method)

julia> x = g(20)
-2.2914735159347884e+302

julia> 1 < x
false

julia> x < -1
true

julia> Float64(x)
0.6714350546186427

So it seems there are multiple issues here:

  1. rand produces a number of huge magnitude
  2. rand produces negative number
  3. the conversion to Float64 (producing a positive number) is not consistent with the < operator
@dzhang314
Copy link
Owner

Hey @nsajko, thanks for your interest in MultiFloats.jl! I finally got around to looking at this today (sorry it took a while), and it turns out this was happening because a Float64x{20} is so long, the exponent underflows past -1024, causing the final limb to overflow to an extremely large number. I've fixed this by adding an explicit underflow check and returning 0.0 if it's hit.

Please note that Float64x{20} is not useful because it is so long, the final component is essentially guaranteed to underflow out of the allowed exponent range for a Float64. In practical usage, you don't want to go past about Float64x8.

You will see the fix in the next release of MultiFloats.jl.

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

No branches or pull requests

2 participants