[Bf-committers] Verse 2005 Errors

Emanuel Greisen blender at emanuelgreisen.dk
Thu Sep 14 17:12:04 CEST 2006


Running GCC4.1.1 the MAX_FLT is defined as __MAX_FLT__ and that is built 
in. But doing some testing I find that the binary rep is:

0x7f7fffff

I am on a 32-bit Pentium 4.



Here is the ugly hack that lead me to belive that the binary constant is 
0x7f7fffff

[code]

#include <iostream>
#include <cstdlib>
#include <float.h>


using namespace std;

int main(int argc, char *argv[])
{
    cout << "Hello, world!" << endl;
    float f(FLT_MAX);
    unsigned char * c = reinterpret_cast<unsigned char *>(&f);
   
    cout << "FLT_MAX: " << ((unsigned int)c[3]) << ","  << ((unsigned 
int)c[2]) << ","  << ((unsigned int)c[1]) << ","  << ((unsigned 
int)c[0]) << "," << std::endl;
   
    unsigned int i = 0x7f7fffff;
    float * f2 = reinterpret_cast<float *>(&i);
    unsigned int * i2 = reinterpret_cast<unsigned int *>(&f);
   
    std::cout << "f:" << f <<",f2:" << *f2 << ",i:" << i << ",i2:" << 
*i2 << std::endl;
   
    return EXIT_SUCCESS;
}


[/code]


More information about the Bf-committers mailing list