This has been giving me trouble over this past week, I'm desperate, can you guys help?
"write C++ code to display the hexadecimal value stored in memory for the floats q and t below,
float q = 0.1,
t = 0.5;"
I've tried all sorts of things, but the output I always get for "q" is 0.1 . Why is this? I've used the simple
std::hex << q <<
And I've even gotten fancy with that whole
setf(std::ios::hex) thing.
My MOST RECENT attempt looks like this:
#include <iostream>
#include <iomanip>
int main()
{
float number;
number = 0.5;
std::cout.setf(std::ios::hex);
std::cout << "what about the hex function?: " << number << "\n";
return (0);
}
This does nothing. Obviously, this is either WAY off, or I'm doing it wrong.
If you guys have ANY ideas, suggestions, comments, please share them! Even the smallest and seemingly insignificant responses will be greatly appreaciated.