Skip to content

Power function broken in Version 1.11.4 #58077

@KlausC

Description

@KlausC

The ^ function delivers numerically wrong results for big negative integer exponents.
The second column shows the correct results.

Related to PR #53967, which should be backported to 1.11 and 1.10.

julia> VERSION
v"1.11.4"

julia> E = prevfloat(1.0)
0.9999999999999999

julia> [ E.^(-2 .^(50:63)) Float64.(big(E).^(-2 .^(50:63))) ]
14×2 Matrix{Float64}:
     1.12352         1.13315
     1.23654         1.28403
     1.35914         1.64872
     1.10235e-7      2.71828
   -54.5981          7.38906
 -8942.87           54.5982
    -6.22028e7    2980.96
    -1.18444e15      8.88611e6
    -1.9329e29       7.8963e13
    -2.44925e57      6.23515e27
    -1.91951e113     3.88771e55
    -5.82523e224     1.51143e111
    Inf              2.28441e222
     1.0            Inf

Compare to the fixed version:

julia> VERSION
v"1.12.0-beta1"

julia> E = prevfloat(1.0)
0.9999999999999999

julia> [ E.^(-2 .^(52:63)) Float64.(big(E).^(-2 .^(52:63))) ]
12×2 Matrix{Float64}:
    1.64872         1.64872
    2.71828         2.71828
    7.38906         7.38906
   54.5982         54.5982
 2980.96         2980.96
    8.88611e6       8.88611e6
    7.8963e13       7.8963e13
    6.23515e27      6.23515e27
    3.88771e55      3.88771e55
    1.51143e111     1.51143e111
    2.28441e222     2.28441e222
   Inf             Inf

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions