Java Utililty Methods Array Sum

List of utility methods to do Array Sum

Description

The list of methods to do Array Sum are organized into topic(s).

Method

bytesum(byte... bytes)
sum
byte total = 0;
for (byte b : bytes) {
    total += b;
return total;
bytesum(byte[] array)
Sum all numbers from array.
byte sum = 0;
for (byte x : array) {
    sum += x;
return sum;
intsum(byte[] array)
Sums the values of elements in an array.
int result = 0;
for (final byte v : array) {
    result += v;
return result;
intsum(byte[] array, int offset, int size)
XOR checksum of a byte array range
int sum = 0;
for (int i = offset; i < offset + size; i++)
    sum ^= array[i];
return sum;
intsum(byte[] array, int offset, int size)
sum
int sum = 0;
for (int i = offset; i < offset + size; i++)
    sum ^= array[i];
return sum;
byte[]sum(byte[] in, byte[] gamma)
componentwise addition modulo 2 (XOR)
byte[] out = new byte[in.length];
for (int i = 0; i < in.length; i++) {
    out[i] = (byte) (in[i] ^ gamma[i]);
return out;
doublesum(double a[], int begin, int end)
sum
double res = 0;
for (int i = begin; i < end; i++) {
    res += a[i];
return res;
doublesum(double values[], int size)
sum
if (values == null) {
    return Double.NaN;
if (size == 0) {
    return 0;
double r = 0;
for (int i = 0; i < size; i++) {
...
doublesum(double... a)
sum
if (a == null) {
    return 0;
if (a.length == 0) {
    return 0;
double sum = 0;
for (double d : a) {
...
doublesum(double... values)
Sums up the values.
double sum = 0.0d;
for (double val : values)
    sum += val;
return sum;