# Inconsistent promotion of unsinged integers

**URL:** <https://discourse.julialang.org/t/inconsistent-promotion-of-unsinged-integers/468>\
**Category:** Internals & Design\
**Created:** [November 21, 2016, 1:18pm UTC](https://discourse.julialang.org/t/inconsistent-promotion-of-unsinged-integers/468 "2016-11-21T13:18:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ethomag](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ethomag/32/421_2.png) [@ethomag](https://discourse.julialang.org/u/ethomag)\
**Post date:** [November 21, 2016, 1:18pm UTC](https://discourse.julialang.org/t/inconsistent-promotion-of-unsinged-integers/468/1 "2016-11-21T13:18:30Z")

</div>

I was surprised when I discovered the following when I was trying to do some fixed-point arithmetics

```julia
julia> UInt64(1) - 2
0xffffffffffffffff
julia> UInt32(1) - 2
-1
julia> UInt16(1) - 2
-1

```

This (inconsistent ?) behavior seems intentional. I found these promotion rules in `base/int.jl`

```julia
promote_rule(::Type{UInt32}, ::Type{Int64}) = Int64
#= ... =#
for T in BitSigned_types
    @eval promote_rule{S<:Union{UInt8,UInt16}}(::Type{S}, ::Type{$T}) =
        $(sizeof(T) < sizeof(Int) ? Int : T)
end
#= ... =#
promote_rule{T<:BitSigned64}(::Type{UInt64}, ::Type{T}) = UInt64

```

I’m sure there is some rationale behind this, as there usually is. But, I can’t see it.

---

<div class="post-metadata">

**Author:** ![martinholters](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/martinholters/32/3690_2.png) [@martinholters](https://discourse.julialang.org/u/martinholters)\
**Post date:** [November 21, 2016, 1:34pm UTC](https://discourse.julialang.org/t/inconsistent-promotion-of-unsinged-integers/468/2 "2016-11-21T13:34:27Z")

</div>

Ref. discussion here: [Int64\*Uint64 · Issue #9292 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/9292)
