testing if just one bit is set...

  • Thread starter .rhavin grobert
  • Start date
J

James Kanze

Presumably "works for any representation" meant that things
OTHER than unsigned were being considered, since unsigned
types use two's complement and nothing else.

Given that two's complement specifies how to represent negative
values, given a base 2 representation for positive values, I
don't see how one can say that unsigned types use two's
complement.
And it's true, said expression does NOT work for
representations other than two's complement. Since almost
everything uses two's complement these days, said expression
will thus work even for signed types on almost everything.

For some sufficiently weak definition of "almost". Whether you
like it or not, machines are still being sold that don't use
two's complement, and at least one of them supports C++. If the
only machines you have to worry about are PC's, fine. You can
ignore portability issues. Otherwise...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top