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: Wed, 13 May 2026 15:42:41 -0700
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <86a4u3j5i6.fsf@linuxsc.com>
References: <10su8cn$am9i$1@dont-email.me> <10tls2u$39j7a$1@dont-email.me> <10tm49i$9d$1@reader1.panix.com> <10tn3so$3j8hc$1@dont-email.me> <10tnj8s$pnq$1@reader1.panix.com> <10tnmk6$3os5b$1@dont-email.me> <10tnnv1$3o0n8$2@dont-email.me> <10tntu0$3r6q3$1@dont-email.me> <865x4vrqgu.fsf@linuxsc.com> <10tqp0l$ktbv$1@dont-email.me> <861pfiq8xc.fsf@linuxsc.com> <10tt6u4$1adha$6@kst.eternal-september.org> <86h5oblg91.fsf@linuxsc.com> <10u1nlo$1l93k$16@dont-email.me> <86v7crjijp.fsf@linuxsc.com> <10u2gg7$2t96p$1@kst.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Wed, 13 May 2026 22:42:42 +0000 (UTC)
Injection-Info: dont-email.me; logging-data="3179643"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18CXp3Izi8rJO2RrCfhNlWYtQpELtULLBw="; posting-host="ace8b6eaa328dcf44f89a3207699c4cb"
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:zMhAl2/tXq7sRNUr3/5zxwtXUq8= sha1:YGCop3iAZYUGt2Wndh2E80V+hQc= sha256:NEEZCyEn08DWZ0UPpbkFcWp9kJpSeBwwejr4RNP3hOc= sha1:nnfEUUQYvTbcIgGM0lUt87IUtPM=
Xref: csiph.com comp.lang.c:398910
Keith Thompson writes:
> Tim Rentsch writes:
> [...]
>
>> There is another difference worth noting. A byte is a unit of
>> storage, whereas octet is a measure of information. The word
>> byte is inherently about memory; the word octet is inherently
>> about value (eight bits of information). For this reason too
>> the name 'octet' is a better choice for a type name than 'byte'.
>
> The words "octet" and "byte" mean different things.
>
> If I were to typedef "byte" as unsigned char, it would be because I
> want to emphasize the fact that a byte object holds one fundamental
> unit of data, not necessarily character data. And I'd probably
> use it in a way that doesn't assume it's 8 bits (unless I have a
> good reason not to need portability). C's conflation of character
> types with "bytes" is IMHO unfortunate; a typedef makes it clearer
> what the type is being used for.
It could, if someone happens to be looking at the typedef. More
often than not what is being looked at is a use of the name, and
not the typedef. Readers don't always have time to look up where
the name is defined, and that's why a good choice of name matters.
> I usually just use "unsigned char" and remember that it's one byte
> (however many bits that is).
I must remember to start using "char unsigned" in preference to
"unsigned char". ;)