Skip to content

^(::AbstractIrrational, ::Integer) should probably behave like ^(::Float64, ::Integer) instead of like ^(::Integer, ::Integer) #55961

Open
@nsajko

Description

using Test
@testset "`^(::AbstractIrrational, ::Integer)`" begin
    @testset "c: $c" for c  (ℯ, π, MathConstants.γ, MathConstants.φ, MathConstants.catalan)
        let e = -1 
            @test c  (c^e)^e
        end    
    end    
end
Test Summary:                        | Pass  Error  Total  Time
`^(::AbstractIrrational, ::Integer)` |    1      4      5  1.6s
  c: ℯ                               |    1             1  0.0s
  c: π                               |           1      1  1.2s
  c: γ                               |           1      1  0.1s
  c: φ                               |           1      1  0.1s
  c: catalan                         |           1      1  0.1s
ERROR: Some tests did not pass: 1 passed, 0 failed, 4 errored, 0 broken.

Among the Irrational constants, only works as a base for exponentiation here, I guess because that case gets forwarded to exp.

I guess the fix is to define a method something like the following:

^(c::AbstractIrrational, n::Integer) = AbstractFloat(c) ^ n

Activity

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

Metadata

Assignees

No one assigned

    Labels

    mathsMathematical functions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions