Skip to content

digits(n, base=-b) fails for n > typemax(n)÷2 #29183

Closed
@StefanKarpinski

Description

digits has the same issue that ndigits had before #29148:

julia> digits(typemax(UInt), base=-2)
ERROR: InexactError: check_top_bit(UInt64, 18446744073709551615)
Stacktrace:
 [1] throw_inexacterror(::Symbol, ::Any, ::UInt64) at ./boot.jl:567
 [2] check_top_bit at ./boot.jl:581 [inlined]
 [3] toInt64 at ./boot.jl:642 [inlined]
 [4] Type at ./boot.jl:717 [inlined]
 [5] Type at ./boot.jl:741 [inlined]
 [6] convert at ./number.jl:7 [inlined]
 [7] #digits!#309(::Int64, ::Function, ::Array{Int64,1}, ::UInt64) at ./intfuncs.jl:747
 [8] #digits! at ./none:0 [inlined]
 [9] #digits#308(::Int64, ::Int64, ::Function, ::Type{Int64}, ::UInt64) at ./intfuncs.jl:709
 [10] #digits at ./none:0 [inlined]
 [11] #digits#307 at ./intfuncs.jl:705 [inlined]
 [12] (::getfield(Base, Symbol("#kw##digits")))(::NamedTuple{(:base,),Tuple{Int64}}, ::typeof(digits), ::UInt64) at ./none:0
 [13] top-level scope at none:0

Can probably be fixed using the same trick.

Activity

self-assigned this
on Sep 14, 2018
added a commit that references this issue on Sep 14, 2018
4273a98
added
bugIndicates an unexpected problem or unintended behavior
on Sep 14, 2018
goggle

goggle commented on Oct 22, 2019

@goggle
Contributor

This can probably be closed because of #29205.

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

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behavior

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

    Participants

    @StefanKarpinski@goggle@rfourquet

    Issue actions

      digits(n, base=-b) fails for n > typemax(n)÷2 · Issue #29183 · JuliaLang/julia