Skip to content

Instantly share code, notes, and snippets.

@ppdms
Last active February 1, 2024 17:34
Show Gist options
  • Save ppdms/3c52f3a9a86c3b29b561192668ff7849 to your computer and use it in GitHub Desktop.
Save ppdms/3c52f3a9a86c3b29b561192668ff7849 to your computer and use it in GitHub Desktop.
/**
* @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