Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: Safety of casting from 'long' to 'int'
Date: Sun, 31 May 2026 14:43:34 -0700
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <86pl2bdzll.fsf@linuxsc.com>
References: <10su8cn$am9i$1@dont-email.me> <86v7crjijp.fsf@linuxsc.com> <10u394q$1l93l$38@dont-email.me> <86pl2yi0n3.fsf@linuxsc.com> <10u51uq$euq$1@reader1.panix.com> <10u5m4m$uo0d$3@kst.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Sun, 31 May 2026 21:43:36 +0000 (UTC)
Injection-Info: dont-email.me; logging-data="1928342"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18MB/smtJtLrevzZG1OehxvNpscDijE25c="; posting-host="7f8da0c1566d3f9ff33b7bc265315aa3"
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:u0vwbyShnkMzC4ZHp2nVhu7kSnU= sha1:bJh0qRDuqu98UTasxVDaEAx+hiQ= sha256:AgK99YNxYMmmO2Ld5e+LG1zwTcXff4VsKVs3jHoEDqw= sha1:3jEpvYFUvSYUxilCb5mKbuhUdGY=
Xref: csiph.com comp.lang.c:399567
Keith Thompson writes:
> cross@spitfire.i.gajendra.net (Dan Cross) writes:
>
>> In article <86pl2yi0n3.fsf@linuxsc.com>,
>> Tim Rentsch wrote:
>
> [...]
>
>>> My main point is that "byte" and "octet" are talking about
>>> different kinds of things.
>>
>> Not really. It has always been understood to refer to the same
>> kind of thing that "byte" refers to.
>
> I agree, at least for the way I understand the terms. For me,
> "octet" and "byte" refer to the same kind of thing. [...]
An octet is a quantity of information. An octet can be stored in
a computer memory, transmitted over a network wire, shown on a
movie screen, sent in a text message, or written on a piece of
paper.
In C, a byte is an addressable unit of data storage large enough
to hold any member of the basic character set of the execution
environment. There was slightly different wording in the original
C standard, but since C99 the definition has stayed the same up to
the present (specifically, n3220).
If someone wants to use the term "byte" in a C program to mean
something other than the above definition, there is nothing
stopping them from doing so, but it comes with a risk of ambiguity
and confusion. A safer path is to follow the suggestion given by
many people familiar with the C standard, which is to use terms
defined in the C standard in the same way that they are used in
the standard.