From e0af9ad8915e37a9dbcfcdcd49a485431eb8dad7 Mon Sep 17 00:00:00 2001 From: Robert Feldt Date: Tue, 28 Mar 2023 18:11:08 +0200 Subject: [PATCH] doc: clarify that the unsigned type is promoted to (#48973) Clarify that the unsigned type is promoted to, if the types differ only in signedness. This choice was explained by Karpinski in https://github.com/JuliaLang/julia/issues/9292#issuecomment-943740160 but wasn't fully clear in the documentation. --- doc/src/manual/conversion-and-promotion.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/src/manual/conversion-and-promotion.md b/doc/src/manual/conversion-and-promotion.md index 82073c1446bf8..f0c156f21ea62 100644 --- a/doc/src/manual/conversion-and-promotion.md +++ b/doc/src/manual/conversion-and-promotion.md @@ -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