Skip to content

Problems with big numbers #12

@cscherrer

Description

@cscherrer

This package would seem to be a good fit for solving this Discourse question. It's easy to see that we should be able to represent 10^(10^100), since

julia> m = exp(ULogarithmic, floatmax(BigFloat))
exp(5.875653789111587590936911998878442589938516392745498308333779606469323584389875e+1388255822130839282)

julia> log10(log10(m))
1.388255822130839282406840509258088745814167339601572288185265795534139656091031e+18

But when I try, I get

julia> ten = ULogarithmic(big(10.0))
exp(2.302585092994045684017991454684364207601101488628772976033327900967572609677367)

julia> ten^(ten^100)
ERROR: StackOverflowError:
Stacktrace:
     [1] promote_type(#unused#::Type{BigFloat}, #unused#::Type{Logarithmic{BigFloat}})
       @ Base ./promotion.jl:298
     [2] promote_result(#unused#::Type, #unused#::Type, #unused#::Type{BigFloat}, #unused#::Type{Logarithmic{BigFloat}})
       @ Base ./promotion.jl:312
--- the last 2 lines are repeated 39990 more times ---
 [79983] promote_type(#unused#::Type{BigFloat}, #unused#::Type{Logarithmic{BigFloat}})
       @ Base ./promotion.jl:298

At this scale, log2 also has trouble:

julia> log(m)
5.875653789111587590936911998878442589938516392745498308333779606469323584389875e+1388255822130839282

julia> log10(m)
2.551764018185095407552308798312362545661809468659242820931240956675926749716967e+1388255822130839282

julia> log2(m)
Inf

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions