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,910 of 33,346    |
|    Bo Persson to Seungbeom Kim    |
|    Re: "Portability" of operators working o    |
|    12 Feb 12 23:20:33    |
      From: bop@gmb.dk              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)              Yes.              It's perhaps clearer if we just change the sign bit. That will       obviously change the result in a way that depends on the       representation.                     Bo Persson                     --        [ 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