Skip to content

Exponentiation of negative single and half precision fails on nightly #40609

@palday

Description

@palday
julia> versioninfo()
Julia Version 1.7.0-DEV.1011
Commit 4e176ac965* (2021-04-26 08:26 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Xeon(R) E-2288G CPU @ 3.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
Environment:
  JULIA_EDITOR = code
  JULIA_NUM_THREADS = 8

julia> Float64(-2)^5
-32.0

julia> Float32(-2)^5
ERROR: DomainError with -2.0:
log2 will only return a complex result if called with a complex argument. Try log2(Complex(x)).
Stacktrace:
 [1] throw_complex_domainerror(f::Symbol, x::Float64)
   @ Base.Math ./math.jl:33
 [2] _log(x::Float64, base::Val{2}, func::Symbol)
   @ Base.Math ./special/log.jl:304
 [3] log2
   @ ./special/log.jl:268 [inlined]
 [4] ^
   @ ./math.jl:914 [inlined]
 [5] ^
   @ ./math.jl:942 [inlined]
 [6] literal_pow(#unused#::typeof(^), x::Float32, #unused#::Val{5})
   @ Base ./intfuncs.jl:315
 [7] top-level scope
   @ REPL[34]:1

julia> Float16(-2)^5
ERROR: DomainError with -2.0:
log2 will only return a complex result if called with a complex argument. Try log2(Complex(x)).
Stacktrace:
 [1] throw_complex_domainerror(f::Symbol, x::Float64)
   @ Base.Math ./math.jl:33
 [2] _log(x::Float64, base::Val{2}, func::Symbol)
   @ Base.Math ./special/log.jl:304
 [3] log2
   @ ./special/log.jl:268 [inlined]
 [4] ^
   @ ./math.jl:914 [inlined]
 [5] ^
   @ ./math.jl:942 [inlined]
 [6] ^
   @ ./math.jl:944 [inlined]
 [7] literal_pow(#unused#::typeof(^), x::Float16, #unused#::Val{5})
   @ Base ./intfuncs.jl:315
 [8] top-level scope
   @ REPL[40]:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    float16good first issueIndicates a good issue for first-time contributors to Julianeeds testsUnit tests are required for this change

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions