Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- int i = 65535;
- float f = 9.18341e-41;
- char b[4]{ 255,255, 0, 0 };
- std::cout << "int as float " << *((float*) &i) << std::endl;
- std::cout << "float as int "<< *((int*) &f) << std::endl;
- std::cout << "bytes as float " << *((float*) &b) << std::endl;
- std::cout << "bytes as int " <<*((int*) &b) << std::endl;
- std::cout << std::endl;
- for (int count = 0; count < 4; count++)
- {
- std::cout << "b[" << count << "] == " << "i[" << count << "] ? " << (b[count] == ((char*)& i)[count]) << std::endl;
- }
- std::cout << std::endl;
- for (int count = 0; count < 4; count++)
- {
- std::cout << "b[" << count << "] == " << "f[" << count << "] ? " << (b[count] == ((char*)& f)[count]) << std::endl;
- }
- std::cout << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment