C/C++ >> wats wrong with the answer????
Posted by sun_vivek on 16:42:00 02-26-2003
hi pple,
look at the codes.

printf("%ld",1000*1000);

this gives an answer '0' zero.
but the range of longdouble is far more than the answer.
why it dosent gives a write answer.
thankx.
Posted by dxprog on 23:51:00 02-26-2003
Why don't you set the value of a long double variable to 1000*1000 and then printf that instead. [addsig]
Posted by Smerdyakov on 06:47:00 02-27-2003
Maybe because %ld is long int, not long double, eh?

[Lesson: Read the manual. ]
Posted by sun_vivek on 00:16:00 03-05-2003
i know that if i do long a;
a=1000*1000;
printf("%ld",a);
i will get the answer but wats wrong with the code i wrote.
Posted by buzgub on 19:12:00 03-12-2003
You don't run into this problem here, but you need to be aware that as 1000 is an int, the expression 1000 * 1000 will be evaluated with integer multiplication. Therefore, the integer limits apply, so if you did 1000 * 1000 * 1000 * 1000, you would get problems.

I think that's right.