Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 31,909 of 33,346    |
|    Francis Glassborow to Seungbeom Kim    |
|    Re: "Portability" of operators working o    |
|    12 Feb 12 23:20:09    |
      From: francis.glassborow@btinternet.com              On 11/02/2012 23:20, Seungbeom Kim wrote:       > On 2012-02-10 14:14, Francis Glassborow wrote:       >> How an actual system represents values is irrelevant, the C++ Standard       >> requires that an implementation conforms to the abstract machine. In C++       >> this abstract machine is required to represent integer types in a pure       >> binary form (there are three options, two's complement (most common)       >> ones complement (I think this is very rare these days), sign and       >> magnitude (again rare). There are no other options. The bitwise       >> operators will operate on the 'bits' even if the underlying system uses       >> some other representation.       >       > Then, is the result of a bitwise operation implementation-defined,       > depending on the representation of negative numbers?       > For example, how is the result of (3& -3) defined -- can it be       > any of 0, 1, or 3?       >       > -3 = 11..1101 (2C)       > -3 = 11..1100 (1C)       > -3 = 10..0011 (SM)       >       I believe so, sorry too lazy to reread the Standard to determine if it       agrees with my beliefs              It is generally unwise to apply bit operators to signed integer types if       the code needs maximal portability.                     --        [ See http://www.gotw.ca/resources/clcm.htm for info about ]        [ comp.lang.c++.moderated. First time posters: Do this! ]              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca