Reputation: 661
I'm implementing a Skein hash function in Java, and I have a problem with a part where some additions where modulo 2^64. As I we know, long in java has max value = 2^63-1. So my problem is, how to implement this modulo operation. (All operations in Skein are on 64bit words.)
Upvotes: 7
Views: 1021
Reputation: 11433
In addition to Peter's answer, I want to suggest taking a look at the great Guava library. It has a class UnsignedLongs which offers several utility functions for working with longs treating them as unsigned. This might be helpful for you.
Upvotes: 2
Reputation: 533492
long
in Java is 64-bit so all operations are mod 2^64 already. You don't have to do anything extra to make that happen.
Is the problem that you don't know how to handle signed values?
Is this something you want or is it something you are trying to avoid?
Upvotes: 6