Deutsch English Français Italiano |
<v9bmqu$2v3e1$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Bart <bc@freeuk.com> Newsgroups: comp.lang.c Subject: Re: how cast works? Date: Mon, 12 Aug 2024 02:00:15 +0100 Organization: A noiseless patient Spider Lines: 27 Message-ID: <v9bmqu$2v3e1$1@dont-email.me> References: <v8vlo9$2oc1v$1@dont-email.me> <slrnvb7kis.28a.dan@djph.net> <v929ah$3u7l7$1@dont-email.me> <87ttfu94yv.fsf@nosuchdomain.example.com> <v93a3t$6q7v$1@dont-email.me> <v93e2q$8put$1@dont-email.me> <87bk228uzg.fsf@nosuchdomain.example.com> <86ttfqin3x.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 03:00:14 +0200 (CEST) Injection-Info: dont-email.me; posting-host="53b71da8aa6a1f55b86d602b5a60be5f"; logging-data="3116481"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX186ChxPvxO/rgtpVAriKnwT" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:6CLWp2CsddRrLvUU+PCiNiOEyHM= In-Reply-To: <86ttfqin3x.fsf@linuxsc.com> Content-Language: en-GB Bytes: 1971 On 12/08/2024 01:46, Tim Rentsch wrote: > Keith Thompson <Keith.S.Thompson+u@gmail.com> writes: > >> Bart <bc@freeuk.com> writes: >> [...] >> >>> Take: >>> >>> int a; double x; >>> >>> x = (double)a; >>> >>> The cast is implicit here but I've written it out to make it clear. >> >> [...] >> >> The *conversion* could be done implicitly, but you've used a cast (i.e., >> an explicit conversion) to make it clear. > > The statement assigning to x performs two conversions: an explicit > one caused by the cast, and an implicit one caused by the assignment > operation. The 'x' term is the other side of the cast from the 'a' term. So after '(double)a' has been evaluated, both sides of '=' have the type 'double', so no further conversion is needed.