Deutsch English Français Italiano |
<casting-20240808134403@ram.dialup.fu-berlin.de> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!fu-berlin.de!uni-berlin.de!not-for-mail From: ram@zedat.fu-berlin.de (Stefan Ram) Newsgroups: comp.lang.c Subject: Re: how cast works? Date: 8 Aug 2024 12:44:46 GMT Organization: Stefan Ram Lines: 18 Expires: 1 Jul 2025 11:59:58 GMT Message-ID: <casting-20240808134403@ram.dialup.fu-berlin.de> References: <v8vlo9$2oc1v$1@dont-email.me> <slrnvb7kis.28a.dan@djph.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de 7YmjNHrtBA83jubj+3z1rwPx/yofX0PRZlfDrzH45ik/Fa Cancel-Lock: sha1:IBFUgKV5UG7qv46aJ88///WEVV4= sha256:7fhE/D3tnrUuTk7vOepUsB0KFSMTns566DcXTTyPxg4= X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved. Distribution through any means other than regular usenet channels is forbidden. It is forbidden to publish this article in the Web, to change URIs of this article into links, and to transfer the body without this notice, but quotations of parts in other Usenet posts are allowed. X-No-Archive: Yes Archive: no X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some services to mirror the article in the web. But the article may be kept on a Usenet archive server with only NNTP access. X-No-Html: yes Content-Language: en-US Bytes: 2080 Dan Purgert <dan@djph.net> wrote or quoted: >I don't know what happens when you're changing datatype lengths, but if >they're the same length, it's just telling the compiler what the >variable should be treated as (e.g. [8-bit] int to char) Casting doesn't tweak a value right where it sits, so you don't have to stress about resizing memory. (It hands you an rvalue, not an lvalue.) Casting isn't just about variables; it's all about expressions. The whole casting concept hails from Algol. Basically, casting is like flipping a value from one type to another (as specified by the cast). But you got to tackle each pair of data types on its own, and that's way more than we can dive into here!