<p dir="auto">We've had quite a few issues crop up about how to define types of outputs given inputs. My view is that this is revealing limitations in the promotion system. A proposal to deal with this might be to define arithmetic on types.</p>
<p dir="auto">For example, here would be some rules:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Int*Int == Int
Int+Int == Int
Meter{Float64}+Meter{Float64} == Meter{Float64}
Meter{Float64}*Meter{Float64} == Meter{Float64}^2
Meter{Float64}/Meter{Float64} == Float64
Matrix{Int}+Matrix{Float64} == Matrix{Float64}"><pre class="notranslate"><code class="notranslate">Int*Int == Int
Int+Int == Int
Meter{Float64}+Meter{Float64} == Meter{Float64}
Meter{Float64}*Meter{Float64} == Meter{Float64}^2
Meter{Float64}/Meter{Float64} == Float64
Matrix{Int}+Matrix{Float64} == Matrix{Float64}
</code></pre></div>
<p dir="auto">and so on.</p>
<p dir="auto">3^(-5) gives a Float64 of value 0.004115226337448558</p>
<p dir="auto">while</p>
<p dir="auto">@code_llvm ^(3, -5) emits the following llvm code</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=";  @ intfuncs.jl:221 within `^'
define i64 @&quot;julia_^_11097&quot;(i64, i64) {
top:
  %2 = call i64 @julia_power_by_squaring_990(i64 %0, i64 %1)
  ret i64 %2
}"><pre class="notranslate"><code class="notranslate">;  @ intfuncs.jl:221 within `^'
define i64 @"julia_^_11097"(i64, i64) {
top:
  %2 = call i64 @julia_power_by_squaring_990(i64 %0, i64 %1)
  ret i64 %2
}
</code></pre></div>
<p dir="auto">which indicates that the function has an integer return type.</p>
<p dir="auto">The output of versioninfo() is as follows-</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Julia Version 1.2.0
Commit c6da87ff4b (2019-08-20 00:03 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.6.0)
  CPU: Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, broadwell)
Environment:
  JULIA_EDITOR = atom  -a
  JULIA_NUM_THREADS = 2"><pre class="notranslate"><code class="notranslate">Julia Version 1.2.0
Commit c6da87ff4b (2019-08-20 00:03 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.6.0)
  CPU: Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, broadwell)
Environment:
  JULIA_EDITOR = atom  -a
  JULIA_NUM_THREADS = 2
</code></pre></div>