Deutsch English Français Italiano |
<v9cpfm$38p3u$2@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Vir Campestris <vir.campestris@invalid.invalid> Newsgroups: comp.lang.c Subject: Re: how cast works? Date: Mon, 12 Aug 2024 11:51:34 +0100 Organization: A noiseless patient Spider Lines: 28 Message-ID: <v9cpfm$38p3u$2@dont-email.me> References: <v8vlo9$2oc1v$1@dont-email.me> <v8vm2i$2oc1v$2@dont-email.me> <86y152in9n.fsf@linuxsc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 12 Aug 2024 12:51:34 +0200 (CEST) Injection-Info: dont-email.me; posting-host="9e8135423bf13137e8c00c2554caafde"; logging-data="3433598"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18sJ2hM6bEoTe80efmxmAEcgUsuGPZ1/i4=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:bnEtETH5o0rjNgyWESk/V1Nh+yQ= In-Reply-To: <86y152in9n.fsf@linuxsc.com> Content-Language: en-GB Bytes: 2145 On 12/08/2024 01:43, Tim Rentsch wrote: > Thiago Adams <thiago.adams@gmail.com> writes: > >> I also would like to understand better why integer promotions were created. >> >> My guess..it is because the values are used in registers and there is >> no "char" size register so the values are converted in a bigger type. >> Is my guess correct? > > The motivations for integer promotion rules are purely historical. > You're looking for answers in the wrong places. > > Also, it would be better for your understanding of C if you would > stop thinking about what is going on at the level of actual > hardware. Doing that serves to confuse a lot more than it helps. I think I feel my ears burning! Thiago, an example - if I have two integers, and I want to multiply them, the output may be too big to fit in an integer. Cast them both to a size twice as big, multiply them, and you know the output will fit. You can then check it will fit back into an int. Andy -- Being careful of course because there's no guarantee than long is bigger than int...