🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3540

Re: Integral promotion.

#3540
From: Gene Wirchenko
Date: Sat, 17 Feb 1996 17:56
35 lines
1793 bytes
tada@athena.mit.edu (Michael J Zehr) wrote:

[snip]

>So while 

>x1 and x2 are shorts and remain shorts regardless of how the compiler
>sees fit to pass them to the "test" function, in the expression "x1 +
>x2" there values are converted to ints.  Thus the type of "x1 + x2" is
>an int and it is *this* that is being converted to a short during the
>assignment to result.

>The original poster was mostly right in the last sentence -- the values
>of short variables in an expression are convert to int if an int can
>hold all possible values, otherwise converted to an unsigned int.  It is
>neither the arguments nor the parameters that are being converted.

     To me, this means that many arithmetic operators can not be done
on short variables without conversion if int is bigger than short.  Is
this what you meant?

     To elaborate, addition could result in a short overflow, but not
int if int is bigger, so it'll be converted.  Similar statements can
be made for subtraction, multiplication, division, and probably
others.

>-michael j zehr

Sincerely,

Gene Wirchenko

C Pronunciation Guide:
     y=x++;     "wye equals ex plus plus semicolon"
     x=x++;     "ex equals ex doublecross semicolon"
Technical Details
Message-ID: <4g54sd$alc@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4fstj7$2l6@solutions.solon.com> <4fvk8c$eq8@solutions.solon.com> <4g174t$mq7@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: genew@mindlink.bc.ca (Gene Wirchenko)
Newsgroups: comp.std.c,comp.lang.c.moderated
Subject: Re: Integral promotion.
Date: 17 Feb 1996 11:56:29 -0600
Organization: MIND LINK! - British Columbia, Canada
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4g54sd$alc@solutions.solon.com>
References: <4fstj7$2l6@solutions.solon.com> <4fvk8c$eq8@solutions.solon.com> <4g174t$mq7@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com
X-Newsreader: Forte Free Agent 1.0.82