Last active
February 1, 2024 17:34
-
-
Save ppdms/3c52f3a9a86c3b29b561192668ff7849 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @author : Vasileios Papadimas (papadimas@protonmail.com) | |
* @file : floatExpose.cpp | |
* @created : Saturday Oct 28, 2023 14:28:58 EEST | |
*/ | |
#include <bitset> | |
#include <iostream> | |
#include <ostream> | |
using std::cout; | |
using std::endl; | |
int main(int argc, char* argv[]) { | |
float val = 5168.19; | |
for (unsigned char* pointer = reinterpret_cast<unsigned char*>(&val) + 3; | |
pointer >= reinterpret_cast<unsigned char*>(&val); --pointer) { | |
unsigned char byte = *pointer; | |
cout << std::hex << std::bitset<8>(static_cast<int>(byte)) << " "; | |
} | |
cout << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment