I am trying to access the individual bytes in a floating point number and I am getting unexpected results
- by oweinh
So I have this so far:
#include <iostream>
#include <string>
#include <typeinfo>
using namespace std;
int main ()
{
float f = 3.45; // just an example fp#
char* ptr = (char*)&f; // a character pointer to the first byte of the fp#?
cout << int(ptr[0]) << endl; // these lines are just to…