Skip to content

Commit

Permalink
doc: clarify that the unsigned type is promoted to (#48973)
Browse files Browse the repository at this point in the history
Clarify that the unsigned type is promoted to, if the types differ only
in signedness. This choice was explained by Karpinski in
#9292 (comment)
but wasn't fully clear in the documentation.
  • Loading branch information
robertfeldt authored Mar 28, 2023
1 parent 7d2491d commit 045a392
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions doc/src/manual/conversion-and-promotion.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,11 @@ julia> promote(1 + 2im, 3//4)
```

Floating-point values are promoted to the largest of the floating-point argument types. Integer
values are promoted to the larger of either the native machine word size or the largest integer
argument type. Mixtures of integers and floating-point values are promoted to a floating-point
type big enough to hold all the values. Integers mixed with rationals are promoted to rationals.
Rationals mixed with floats are promoted to floats. Complex values mixed with real values are
promoted to the appropriate kind of complex value.
values are promoted to the largest of the integer argument types. If the types are the same size
but differ in signedness, the unsigned type is chosen. Mixtures of integers and floating-point
values are promoted to a floating-point type big enough to hold all the values. Integers mixed
with rationals are promoted to rationals. Rationals mixed with floats are promoted to floats.
Complex values mixed with real values are promoted to the appropriate kind of complex value.

That is really all there is to using promotions. The rest is just a matter of clever application,
the most typical "clever" application being the definition of catch-all methods for numeric operations
Expand Down

0 comments on commit 045a392

Please sign in to comment.