#include <limits>
#include <iostream>
using namespace std;

// http://www.who.is.free.fr/wiki/doku.php?id=type
// g++ -O0    main.cpp   -o main
// g++ -O1    main.cpp   -o main 

int main() 
{
    cout << hex << std::numeric_limits<int32_t>::max() << endl; // 7fffffff
    cout << hex << (int32_t) ((float) std::numeric_limits<int32_t>::max()) << endl; // 80000000
    cout << hex << (int32_t) (static_cast<float>(std::numeric_limits<int32_t>::max())) << endl; // 80000000
    cout << hex << (int32_t) (static_cast<float>(std::numeric_limits<float>::max())) << endl; // 80000000
    
    printf("0x%x\n", (int) (float) 0x80000000); //0x7fffffff
}

To ExplaiN LimitS CasT

type.txt · Last modified: 2022/04/16 12:24 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki