gcc/g++ 4.9.2; Unexpected output?
Learning C++ from a book.
I set a value for an unsigned long int called red:
unsigned long int red = 0xFF0000UL;
The hexadecimal output of red is: 0x00FF0000
Which is what I expected.
However, the output for ~red is:
FFFFFFFFFF00FFFF
Which is definitely not what I expected.
I expected FF00FFFF
The source code that produced the unexpected output is:
// PROGRAM 03-04: USING THE BITWISE OPERATORS
#include <iostream>
#include <iomanip>
using std::hex;
using std::cout;
using std::endl;
using std::setw;
using std::setfill;
int main() {
unsigned long red = 0xFF0000UL; // Variable representing the color red
unsigned long white = 0xFFFFFFUL; // Variable representing the color white
cout << hex; // Set the output format to hexadecimal
cout << setfill
I copy/pasted and the copy/paste was incomplete.
PLEASE DISREGARD THIS QUESTION. I'LL DELETE IT WHEN I FIGURE OUT HOW.