Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cf-dev] Bug in Option.getLongValue()?

new Option(10, 8611588610L).getLongValue()

returns 21654020.
The bit shift is performed on int32, so overflows on any value that is longer than 32bits. A cast should fix it:

public long getLongValue() {
   long ret = 0;
   for (int i=0;i<value.length;i++) {
        ret += (long) (value[value.length - i - 1] & 0xFF) << (i*8);
    }
    return ret;
}


Back to the top