home bbs files messages ]

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,899 of 33,346   
   Francis Glassborow to All   
   Re: "Portability" of operators working o   
   10 Feb 12 14:14:47   
   
   6f7a45bb   
   From: francis.glassborow@btinternet.com   
      
   On 10/02/2012 10:09, Camilo Bravo Valdés wrote:   
   > Hi, guys.   
   >   
   > Do operators like&, | and ^ "assume" an internal representation of   
   > the integers they work on? I mean, on a (hypothetical?) computer that   
   > does not represent numbers in base 2, will they "work" properly, or is   
   > there an abstraction layer between the inner representation and what a   
   > C++'s compiler "understands"?   
   >   
   > Thanks in advance,   
   > Camilo   
   >   
   >   
   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.   
      
   IOWs you need not be concerned as to how the hardware stores and   
   represents values (this actually would place a considerable burden in   
   implementing C++ on hardware that, for example, used a ternary system   
   with the lowest level of information being a 3-state circuit)   
      
      
   --   
         [ 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