Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > alt.comp.lang.c > #617

Re: portable way to get highest bit set?

From Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups comp.lang.c, alt.comp.lang.c
Subject Re: portable way to get highest bit set?
Date 2023-10-11 17:50 -0700
Organization None to speak of
Message-ID <87cyxku0ji.fsf@nosuchdomain.example.com> (permalink)
References (1 earlier) <20231011102714.44a870af4dfe68f756974953@g{oogle}mail.com> <ug6huc$1rvp1$1@dont-email.me> <ug6nvv$1va0l$1@dont-email.me> <ug7een$1rvp2$3@dont-email.me> <ug7evl$243f3$1@dont-email.me>

Cross-posted to 2 groups.

Show all headers | View raw


Bart <bc@freeuk.com> writes:
> On 12/10/2023 01:25, candycanearter07 wrote:
>> On 10/11/23 13:02, Richard Harnden wrote:
>>> Why 0x100000000 and not 0x800000000?

I think there's an extra 0 on both of those constants.

>> Wait, how do you specify a binary constant again?
>
> Use 0b rather than 0x. But without numeric separators, you will need
> to count carefully if you have up to 64 bits.
>
> Easier might be to write 1U<<31 or 1ULL<<63.

C does not currently support binary constants.  C23 adds them, and gcc
and clang both support them as an extension (some other compilers might
also).

In C23, a binary integer constant starts with "0b" or "0B".

C23 will also allow apostrophe as a digit separator (a feature borrowed
from C++), so you can write 0b1100'1001 -- but don't count on any
pre-C23 compilers supporting that as an extension.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Back to alt.comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

portable way to get highest bit set? candycanearter07 <no@thanks.net> - 2023-10-11 01:56 -0500
  Re: portable way to get highest bit set? Anton Shepelev <anton.txt@g{oogle}mail.com> - 2023-10-11 10:27 +0300
    Re: portable way to get highest bit set? David Brown <david.brown@hesbynett.no> - 2023-10-11 11:31 +0200
      Re: portable way to get highest bit set? Anton Shepelev <anton.txt@g{oogle}mail.com> - 2023-10-11 12:33 +0300
        Re: portable way to get highest bit set? David Brown <david.brown@hesbynett.no> - 2023-10-11 13:58 +0200
          Re: portable way to get highest bit set? Anton Shepelev <anton.txt@g{oogle}mail.com> - 2023-10-11 15:17 +0300
            Re: portable way to get highest bit set? David Brown <david.brown@hesbynett.no> - 2023-10-11 16:22 +0200
              Re: portable way to get highest bit set? Anton Shepelev <anton.txt@g{oogle}mail.com> - 2023-10-11 18:08 +0300
              Re: portable way to get highest bit set? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-10-11 17:20 +0100
                Re: portable way to get highest bit set? David Brown <david.brown@hesbynett.no> - 2023-10-11 18:28 +0200
    Re: portable way to get highest bit set? candycanearter07 <no@thanks.net> - 2023-10-11 11:19 -0500
      Re: portable way to get highest bit set? David Brown <david.brown@hesbynett.no> - 2023-10-11 18:45 +0200
      Re: portable way to get highest bit set? Ian C <deathstation9000@gmail.com> - 2023-10-11 18:03 +0100
        Re: portable way to get highest bit set? candycanearter07 <no@thanks.net> - 2023-10-11 19:26 -0500
      Re: portable way to get highest bit set? Richard Harnden <richard.nospam@gmail.invalid> - 2023-10-11 19:02 +0100
        Re: portable way to get highest bit set? candycanearter07 <no@thanks.net> - 2023-10-11 19:25 -0500
          Re: portable way to get highest bit set? Bart <bc@freeuk.com> - 2023-10-12 01:35 +0100
            Re: portable way to get highest bit set? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-10-11 17:50 -0700
            Re: portable way to get highest bit set? candycanearter07 <no@thanks.net> - 2023-10-11 20:03 -0500
  Re: portable way to get highest bit set? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-10-11 13:56 +0100
  Re: portable way to get highest bit set? Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2023-10-11 14:54 +0000
    Re: portable way to get highest bit set? Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2023-10-12 23:35 +0000
      Re: portable way to get highest bit set? Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2023-10-12 23:47 +0000
  Re: portable way to get highest bit set? Kaz Kylheku <864-117-4973@kylheku.com> - 2023-10-11 17:23 +0000
  Re: portable way to get highest bit set? jak <nospam@please.ty> - 2023-10-11 22:26 +0200
    Re: portable way to get highest bit set? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-10-11 23:58 +0100
      Re: portable way to get highest bit set? jak <nospam@please.ty> - 2023-10-12 09:14 +0200
        Re: portable way to get highest bit set? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-10-12 10:50 +0100
          Re: portable way to get highest bit set? jak <nospam@please.ty> - 2023-10-12 13:35 +0200
            Re: portable way to get highest bit set? Michael S <already5chosen@yahoo.com> - 2023-10-12 15:36 +0300
              Re: portable way to get highest bit set? jak <nospam@please.ty> - 2023-10-12 15:18 +0200
          Re: portable way to get highest bit set? jak <nospam@please.ty> - 2023-10-12 15:09 +0200
            Re: portable way to get highest bit set? jak <nospam@please.ty> - 2023-10-12 23:39 +0200
  Re: portable way to get highest bit set? Blue-Maned_Hawk <bluemanedhawk@invalid.invalid> - 2023-10-11 21:16 +0000
    Re: portable way to get highest bit set? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-10-11 14:30 -0700
      Re: portable way to get highest bit set? Blue-Maned_Hawk <bluemanedhawk@invalid.invalid> - 2023-10-12 13:42 +0000
        Re: portable way to get highest bit set? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-10-12 14:30 -0700
          Re: portable way to get highest bit set? Anton Shepelev <anton.txt@gmail.moc> - 2023-10-13 00:50 +0300
            Re: portable way to get highest bit set? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-10-12 16:17 -0700
        Re: portable way to get highest bit set? vallor <vallor@cultnix.org> - 2023-10-13 20:12 +0000
          Re: πŸ³οΈβ€πŸŒˆportable way to get highest bit set?πŸ³οΈβ€πŸŒˆ πŸŒˆπŸ’πŸŒ»πŸŒΊπŸŒΉπŸŒ»πŸ’πŸŒ·πŸŒΊπŸŒˆJenπŸŒˆπŸ’πŸŒ»πŸŒΊπŸŒΉπŸŒ»πŸ’πŸŒ·πŸŒΊπŸŒˆ Dershmender πŸ’πŸŒ»πŸŒΊπŸŒΉπŸŒ»πŸ’πŸŒ·πŸŒΊπŸΆη¬›πŸŒˆπŸ’πŸŒ»πŸŒΊπŸŒΉπŸŒ»πŸ’πŸŒ·πŸŒΊπŸŒˆ <root@127.0.0.1> - 2023-10-17 18:28 +0000
  Re: portable way to get highest bit set? Kaz Kylheku <864-117-4973@kylheku.com> - 2023-10-11 21:57 +0000
    Re: portable way to get highest bit set? Kaz Kylheku <864-117-4973@kylheku.com> - 2023-10-15 05:26 +0000
      Re: portable way to get highest bit set? Michael S <already5chosen@yahoo.com> - 2023-10-15 11:35 +0300
      Re: portable way to get highest bit set? yeti <yeti@tilde.institute> - 2023-10-15 14:26 +0000

csiph-web