jose luis fernandez diaz wrote:

> Hi,

>

> My OS is:

>

> cronos:jdiaz:tmp>uname -a

> HP-UX cronos B.11.11 U 9000/800 820960681 unlimited-user license

>

>

> I compile in 64-bits mode the program below:

>

> cronos:jdiaz:tmp>cat kk.C

> #include <iostream.h>
#include <iostream> // No ".h" extension.

> #include <limits>

>

> int main()

> {
using namespace std;

> long l_min = numeric_limits<long>::min();

> long l_max = numeric_limits<long>::max();

> double d_min = numeric_limits<double>::min();

> double d_max = numeric_limits<double>::max();

> cout << sizeof(long) << " " << sizeof(double) << endl;

> cout << l_min << " " << l_max << " " << d_min << " " << d_max <<

> endl;

>

>

> return 0;

> }

> cronos:jdiaz:tmp>a.out

> 8 8

> -9223372036854775808 9223372036854775807 2.22507e-308 1.79769e+308

>

>

>

> The double and long types have the same size, but the double limits

> are bigger. Can anyone explein this to me ?
Typically, some of the bits representing a double are interpreted as an

exponent, and the rest as a multiplier. Floating-point math results in

approximate results, whereas any operation closed over the field of

integers will give an exact result when applied to long int's (if we

discount {over,under}flow).

http://en.wikipedia.org/wiki/IEEE_fl...point_standard