Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
hex manip
//Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x64 #include <iostream> int main() { using type = unsigned short; // B00F + 25B0 to get D5BF type left = 0xB00F; type right = 0x25B0; type first = ((left & 0xF000) >> 12) + ((right & 0xF000) >> 12); std::cout << "first value " << std::hex << first << std::endl; type second = ((left & 0x0F00) >> 8) + ((right & 0x0F00) >> 8); std::cout << "second value " << std::hex << second << std::endl; type third = ((left & 0x00F0) >> 4) + ((right & 0x00F0) >> 4); std::cout << "third value " << std::hex << third << std::endl; type fourth = (left & 0x000F) + (right & 0x000F); std::cout << "4th value " << std::hex << fourth << std::endl; type total = (first << 12) + (second << 8) + (third << 4) + fourth; std::cout << "total " << std::hex << total << std::endl; }
run
|
edit
|
history
|
help
0
MSVC_example_fscanf_s_and_chars_wchars
#30.2
C++ move/copy constructor and assignment demo
Data structure alignment
PreprocessorVsNamespace
C++ exception
hangman
Implements.cpp
Catching divide-by-zero with /EHc
Compile time creation of class member stl container (const std::array) filled with elements.