-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Open
Labels
bignumsBigInt and BigFloatBigInt and BigFloatcorrectness bug ⚠Bugs that are likely to lead to incorrect results in user code without throwingBugs that are likely to lead to incorrect results in user code without throwingmathsMathematical functionsMathematical functions
Description
Hi,
When doing big"2" << <big_number>
it yields 0
. I am assuming it is because big"2"^<big_number>
throws an error, but I have not yet tested this. Here is a reproducer on 1.11.3:
[xxx@fedora ~]$ julia
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.11.3 (2025-01-21)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> _q = big"338529080896108965767114525934749117223216740941376711175117801548757039464925265185456890196066591384483538988140720866125823957951605413309645322444478475882910613426157401827900611393402398255676835299789253650685614604706767318106611143888606425239677611402987117990498540999873668868860546995543503171780419583331612111661293341988510184240889590244574477120700917"
338529080896108965767114525934749117223216740941376711175117801548757039464925265185456890196066591384483538988140720866125823957951605413309645322444478475882910613426157401827900611393402398255676835299789253650685614604706767318106611143888606425239677611402987117990498540999873668868860546995543503171780419583331612111661293341988510184240889590244574477120700917
julia> big"2"<<_q
0
julia> big"2"<<5
64
julia> big"2"^_q
ERROR: OverflowError: exponent 338529080896108965767114525934749117223216740941376711175117801548757039464925265185456890196066591384483538988140720866125823957951605413309645322444478475882910613426157401827900611393402398255676835299789253650685614604706767318106611143888606425239677611402987117990498540999873668868860546995543503171780419583331612111661293341988510184240889590244574477120700917 is too large and computation will overflow
Stacktrace:
[1] (::Base.GMP.var"#throw1#3")(y::BigInt)
@ Base.GMP ./gmp.jl:629
[2] bigint_pow(x::BigInt, y::BigInt)
@ Base.GMP ./gmp.jl:642
[3] ^(x::BigInt, y::BigInt)
@ Base.GMP ./gmp.jl:647
[4] top-level scope
@ REPL[5]:1
Metadata
Metadata
Assignees
Labels
bignumsBigInt and BigFloatBigInt and BigFloatcorrectness bug ⚠Bugs that are likely to lead to incorrect results in user code without throwingBugs that are likely to lead to incorrect results in user code without throwingmathsMathematical functionsMathematical functions