4

I'm doing some 'early computing' on a 32-bit Windows PC, and looking at the limits.

Now, 2**32 is 4,294,967,296, and I find that

4294967290 + 5  

is perfectly OK, and

    4294967290 + 6 

quite properly overflows.

What puzzles me is that

   429496729 * 10

overflows, although the product, 4294967290, is in range.

Anyone interested?

hlovdal
  • 26,565
  • 10
  • 94
  • 165
John White
  • 131
  • 1
  • 3
  • 19

1 Answers1

4

In the absense of any code, I'd guess 429496729 gets implicitly typed as signed integer, for which 4294967290 is too much.

GSerg
  • 76,472
  • 17
  • 159
  • 346
  • You beat me to it. The result is probably negative to prove it. – phkahler Mar 02 '11 at 14:19
  • Thanks fellows, quite right. Actually there was no code, but the Visual C 6 debugger watch window (used for my 'probing') evaluates numeric integers as signed. Quite reasonably actually. All is well with unsigned int. – John White Mar 04 '11 at 05:49