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?

3
  • what environment are you using? Your compiler / interpreter may be doing some inexact bounds checking. Commented Mar 2, 2011 at 14:00
  • That's not fixed point by the way, it's integer. Fixed point is integer with scaling (for example, 100 = 1.00, 4323 = 43.23, and so on). Commented Mar 2, 2011 at 14:05
  • Which programming language do you use? Commented Mar 2, 2011 at 15:41

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

2 Comments

You beat me to it. The result is probably negative to prove it.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.