boon/src/main/java/org/boon/primitive/Int.java
public static int sum( int[] values, int start, int length ) {
        long sum = 0;
        for (int index = start; index < length; index++ ) {
            sum+= values[index];
        }

        if (sum < Integer.MIN_VALUE) {
            die ("overflow the sum is too small", sum);
        }


        if (sum > Integer.MAX_VALUE) {
            die ("overflow the sum is too big", sum);
        }

        return (int) sum;


    }
public static int sum( int[] values, int start, int length ) {
        long sum = 0;
        for (int index = start; index < length; index++ ) {
            sum+= values[index];
        }

        if (sum < Integer.MIN_VALUE) {
            die ("overflow the sum is too small", sum);
        }


        if (sum > Integer.MAX_VALUE) {
            die ("overflow the sum is too big", sum);
        }

        return (int) sum;


    }
public static int sum ( int [ ] values , int start , int length ) { long sum = 0 ; for ( int index = start ; index < length ; index ++ ) { sum += values [ index ] ; } if ( sum < Integer . MIN_VALUE ) { die ( "overflow the sum is too small" , sum ) ; } if ( sum > Integer . MAX_VALUE ) { die ( "overflow the sum is too big" , sum ) ; } return ( int ) sum ; }
Sum
Provides overflow protection.
@param values values in int
@return sum
Sum Provides overflow protection .