B
BobR
arnuld said:i think, -2147483648 is too big to fit in a double.
WHAT?
int big( -2147483648 ); // int is 32bit on my machine
cout<<" big="<<big<<std::endl;
// out: big=-2147483648
// include <limits>
std::cout<<" dbl min() ="
<< std::numeric_limits<double>::min()<<std::endl;
std::cout<<" dbl max() ="
<< std::numeric_limits<double>::max()<<std::endl;
std::cout <<" dbl digits ="
<<(std::numeric_limits<double>::digits)<<std::endl;
std::cout<<" LD digits ="
<<(std::numeric_limits<long double>::digits)<<std::endl;
/* - output - (on my machine)
dbl min() =0.000000 // note: only precision(6)
dbl max() =1.79769e+308
dbl digits =53 // 'digits' is num of bits
LD digits =64
*/
Compare those 'digits' with int, long, long long(if you have it) digits.
When you are not sure, test it.