View Single Post
 09-09-2013, 06:32 PM PM User | #2 Fou-Lu God Emperor     Join Date: Sep 2002 Location: Saskatoon, Saskatchewan Posts: 16,595 Thanks: 4 Thanked 2,597 Times in 2,566 Posts Yep, that's correct. Integers are 32-bits in size, and java does not allow you to specify as an unsigned integer, so the maximum size you have available is 1 << 31 - 1 or 2,147,483,647. Any number larger than this uses the 32nd bit, which dictates the signed of the number and it becomes negative (see two's complement notation for information on this) effectively counting up towards 0. This is integer overflow. I can't give the answer for the special question though as that would defeat the purpose. You can write an algorithm that effectively converges a known high and a known low though. Choose a divide and conquer approach and it can calculate the max correct in both the algorithms. They have potential for difference since one utilizes a division which may at one point truncate the values when stuffing the float into an int. __________________ PHP Code: ``` header('HTTP/1.1 420 Enhance Your Calm');  ```