On Sunday 20 June 2010 13:25:00 Shachar Shemesh wrote: > Hi all, > > I'm trying to calculate the result of a string hash function in perl. I > need an explicit function, as the perl output is used to create a C > program, that will then use that very same hash function. Please, do not > direct me to perl's excellent hash handling. I know it's there. I use it > where applicable. This is not one of those cases. > > The hash function I'm using is sdbm hash function > (http://www.cse.yorku.ca/~oz/hash.html). To calculate it, I need to > perform integer arithmetics, knowing full well it may overflow. It is > okay for it to overflow, as I only need the bottom 32 bits. In fact, my > code ANDs the result with 0xffffffff, to make sure that, on 64 bit > platforms, I only get the bottom 32 bits. > > Here's the problem. When the integer gets too big, Perl replaces it with > MAXINT. On 64 bit platforms, that's not too bad - I can simply truncate > to 32 bits after each operation. On 32 bit platforms, I'm a bit at a > loss as to what to do. > > Any suggestions on how to get the C integer semantics out of perl? I'd google for "perl long long"
# > > Shachar > _______________________________________________ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il