| Deutsch English Français Italiano |
|
<v8o9g2$4ncb$1@raubtier-asyl.eternal-september.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!2.eu.feeder.erje.net!feeder.erje.net!news.swapon.de!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail From: Bonita Montero <Bonita.Montero@gmail.com> Newsgroups: comp.lang.c Subject: Re: What is your opinion about unsigned int u = -2 ? Date: Sun, 4 Aug 2024 18:16:02 +0200 Organization: A noiseless patient Spider Lines: 28 Message-ID: <v8o9g2$4ncb$1@raubtier-asyl.eternal-september.org> References: <v8dfo9$1k7cg$1@dont-email.me> <pan$d2c8a$8c54ac9f$29a202e0$12c6ce86@invalid.invalid> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 04 Aug 2024 18:16:03 +0200 (CEST) Injection-Info: raubtier-asyl.eternal-september.org; posting-host="cca460a5e73b1f123396303db8231286"; logging-data="155019"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+icLvCQnQHyrpY9mLF4QElaYj/l68zpQw=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:hyiPNuKOhkNIGBH30ZxC1yrhuQY= In-Reply-To: <pan$d2c8a$8c54ac9f$29a202e0$12c6ce86@invalid.invalid> Content-Language: de-DE Bytes: 1905 Am 01.08.2024 um 08:34 schrieb Blue-Maned_Hawk: > Thiago Adams wrote: > >> What is your opinion about this: >> >> unsigned int u1 = -1; >> >> Generally -1 is used to get the maximum value. >> Is this guaranteed to work? > > Whether or not it is, i would prefer to use the UINT_MAX macro to make the > code clearer. > >> How about this one? >> >> unsigned int u2 = -2; >> Does it makes sense? Maybe a warning here? > > I cannot think of any situations where that would make sense, but i also > cannot guarantee that there are not any. With ... u &= -2; .... you reset the lowest bit. Similar with ... u &= -256; .... you reset the lowest eight bits.