WHY IS 65536*65536==0.....

Правка en2, от ppp, 2020-10-18 14:14:18

HELLO THERE, I HAVE RECENTLY TRIED TO SOLVE A PROBLEM [problem:1428A] AND CAME THROUGH AN INTERESTING FACT...I HAVE USED AN IF CONDITION LIKE THIS: if(abs(a-b)*abs(c-d)!=0; AND I WAS GETTING WRONG OUTPUT FOR TEST CASE a=1 c=1 b=65537 d=65537.

THEN I HAVE CHECKED FEW VALUES: cout<<65535*65535<<endl;//-131071.

cout<<65536*65536<<endl;//0.

cout<<65537*655367<<endl;//1114119.

SO I CAME TO CONCLUSION THAT SOME OVERFLOW THING IS HAPPENING HERE...

SO BE BE CAREFUL WHEN THERE IS CHANCE OF GETTING 65536*65536==0 IN YOUR CODE.

ALSO I WOULD LIKE TO KNOW SUCH CORNER CASES IF U KNOW ANY.

THANK YOU AND HAVE A NICE DAY;)

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en4 Английский ppp 2020-10-18 15:24:47 631
en3 Английский ppp 2020-10-18 14:16:34 4 Tiny change: 'EW VALUES:\n cout<<6' -> 'EW VALUES:..\n\n cout<<6' (published)
en2 Английский ppp 2020-10-18 14:14:18 16 (saved to drafts)
en1 Английский ppp 2020-10-18 14:12:39 714 Initial revision (published)