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: why is there not a ipow version of pow?
Date: Sun, 23 Aug 2026 06:50:55 -0700
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <868q5xymgw.fsf@linuxsc.com>
References: <115eks4$3pn1s$1@dont-email.me> <115f20j$3un9e$1@dont-email.me> <115f64m$ml3$1@raubtier-asyl.eternal-september.org> <115f7h5$1659$2@dont-email.me> <115f7v8$1b5d$1@raubtier-asyl.eternal-september.org> <115facm$1659$3@dont-email.me> <115fchf$2e17$1@dont-email.me> <86y0e62kzd.fsf@linuxsc.com> <115sk02$189sr$4@dont-email.me> <115sm9t$9dju$1@dont-email.me> <115sosc$183lr$7@dont-email.me> <115t35d$e5dr$1@dont-email.me> <115toan$189sr$5@dont-email.me> <115ubgj$pd0i$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Sun, 23 Aug 2026 13:50:56 +0000 (UTC)
Injection-Info: dont-email.me; logging-data="2038578"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18nSmDhER6izz0ecrWHwR2Euw6ZkKKnbok="; posting-host="f66050aa85370b7b068c3e444f0a8412"
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:3oe1E21PKNHuNIN/EKTuFOL5VWI= sha1:NA0KxmS0gWLflU3NHjJlXsdibTQ= sha256:w890wrZCL+Wy2TSSDojc9yn7WzYrjHKL1UIvpmL+fWI= sha1:RhigkmPvxc+xMrK+FxZJhaqsv4o= sha256:VzpjgzkXCJkml51K/VwP/m2AjmsT/EqrCBNClxwsjOI=
Xref: csiph.com comp.lang.c:401434
scott@slp53.sl.home (Scott Lurndal) writes:
> [on using -1 to produce all ones in an unsigned type]
>
> I also dislike that use of -1. I prefer using ~0ul to get all-ones.
A problem with patterns like ~0ul is that they are type specific.
If the type of the destination changes, a wrong value might be the
result. Also constructs using a suffix on an integer constant are
limited in which types they can accommodate. Recently I have found
it useful to employ 128-bit types, including __uint128_t, which
cannot be designated using a suffix. Using cast is even worse. By
contrast using -1 always works, regardless of the target type, and
even for types outside of the standard basic types. If someone
feels the use of -1 needs explaining, that is easily done with a
comment:
some_unsigned_type foo = -1; // all ones
Personally I think every serious C developer should be thoroughly
familiar with the use of -1 in conjunction with unsigned types, and
not even need the comment. But I recognize that some circumstances
may benefit from an explicit gloss.