JuliaMath / Primes.jl

Prime numbers in Julia
Other
99 stars 32 forks source link

`primes` throws exception, when arguments are huge. #76

Closed KlausC closed 4 years ago

KlausC commented 4 years ago

The second call doesn't look fine. The arguments are close to typemax(Int).

julia> primes(2^62-100, 2^62-1)
2-element Array{Int64,1}:
 4611686018427387817
 4611686018427387847

julia> primes(2^63-100, 2^63-1)
ERROR: BoundsError: attempt to access 31-element Array{Int64,1} at index [-26]
Stacktrace:
 [1] getindex at ./array.jl:758 [inlined]
 [2] wheel_index at /home/crusius/.julia/packages/Primes/uaYlp/src/Primes.jl:26 [inlined]
 [3] _primesmask(::Int64, ::Int64) at /home/crusius/.julia/packages/Primes/uaYlp/src/Primes.jl:68
 [4] primes(::Int64, ::Int64) at /home/crusius/.julia/packages/Primes/uaYlp/src/Primes.jl:119
 [5] top-level scope at REPL[91]:1