Recently I am working with the book "The C++ Programming Language 3rd Edition By Bjarne Stroustrup". In this book, the exercise 4.11 question 5. It ask me to print some largest and smallest value. I use the bit method and others work well except *float*, *double* and *long double*.

My system is Ubuntu 12.04 64bit. g++ version: 4.6.3

I check the IEEE's definition of double. It is something like this:

sign bit biased exponent fraction from normalized mantissa

1bit 8 bits 23 bits

My largest float is: Max = 0x 7f7f ffff

Another float is: Test = 0x ffff ffff

The output is: sizeof(long) is 4, Max = 2.1391e+09, the Test = 4.29497e+09

It is confused me that: 1st, the Test should be a negative but output is positive. 2nd, the Test is even larger than the Max.

Is there anyone could help me out here? Thank you!

My system is Ubuntu 12.04 64bit. g++ version: 4.6.3

I check the IEEE's definition of double. It is something like this:

sign bit biased exponent fraction from normalized mantissa

1bit 8 bits 23 bits

My largest float is: Max = 0x 7f7f ffff

Another float is: Test = 0x ffff ffff

The output is: sizeof(long) is 4, Max = 2.1391e+09, the Test = 4.29497e+09

It is confused me that: 1st, the Test should be a negative but output is positive. 2nd, the Test is even larger than the Max.

Is there anyone could help me out here? Thank you!

Topic archived. No new replies allowed.