Created
September 25, 2013 16:40
-
-
Save orontee/6702404 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include <iostream> | |
int main() | |
{ | |
float f(32767); // 32768 | |
signed short sshf = static_cast<signed short>(f); | |
signed short rshf = *(reinterpret_cast<signed short*>(&f)); | |
std::cout << "As float: " | |
<< f << " (" << sizeof(float) << ")\n" | |
<< "Static cast as signed short: " | |
<< sshf << " (" << sizeof(signed short) << ")\n" | |
<< "Reinterpret as signed short: " | |
<< rshf << " (" << sizeof(signed short) << ")\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment