Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: What's the best hashing function? |
| Date | 2015-09-16 19:44 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <87a8smdx1g.fsf@bsb.me.uk> (permalink) |
| References | <0cb8f2b6-59fd-4efa-b29c-7f3a3ffe7fdd@googlegroups.com> <3b4ccbaa-f055-41c1-837c-0a2fcf8ebcb3@googlegroups.com> <mtc8ct$jib$1@dont-email.me> <24708a81-3370-45bb-b7d7-5fd0a595cb1e@googlegroups.com> |
fir <profesor.fir@gmail.com> writes:
> W dniu środa, 16 września 2015 19:22:31 UTC+2 użytkownik D. Aaron Sawyer napisał:
>> On 2015.09.16 13:35, fir wrote:
>> > I encountered recently some example like
>> > this, Though i not tested it
>> >
>> > its in jave i dont know what >>> means
>> >
>> > /** Robert Jenkins' 96 bit Mix Function. */
>> > private static int mix(int a, int b, int c) {
>> > a=a-b; a=a-c; a=a^(c >>> 13);
>> > b=b-c; b=b-a; b=b^(a << 8);
>> > c=c-a; c=c-b; c=c^(b >>> 13);
>> > a=a-b; a=a-c; a=a^(c >>> 12);
>> > b=b-c; b=b-a; b=b^(a << 16);
>> > c=c-a; c=c-b; c=c^(b >>> 5);
>> > a=a-b; a=a-c; a=a^(c >>> 3);
>> > b=b-c; b=b-a; b=b^(a << 10);
>> > c=c-a; c=c-b; c=c^(b >>> 15);
>> > return c;
>> > }
>> >
>>
>> The '>>>' operator is an unsigned right shift (no sign bit
>> propagation on shift).
>> E.g., (-3 >>> 1) or (for 32-bit int) (0xfffffffd >>> 1) results in
>> (0x7ffffffe) or (MAX_INT-1)
>>
>> Compare with (-3 >> 1) or (0xfffffffd >> 1) which results in
>> (0xfffffffe) or (-2)
>>
> alright, tnx
>
> btw, this c >> operator is signed or unsigned (in c language) ?
Both, but c >> n is only defined (by C) for non-negative values of c.
When c is negative, c >> n is implementation defined (most likely it
will be whatever the hardware does).
If you are planning to translate the Java above into portable C, you
should also know that the arithmetic operations might have undefined
results due to overflow. If it were down to me, I'd just re-write it to
use undefined types, at least internally. If you need to have a signed
result (you probably don't -- that's most likely a hang-over from the
time when Java did not have unsigned types) you can avoid undefined
behaviour that stems from the conversion by using a union. That has
it's own issues, of course, but they are likely to be rarer than a trap
on overflow.
--
Ben.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: What's the best hashing function? fir <profesor.fir@gmail.com> - 2015-09-16 09:35 -0700
Re: What's the best hashing function? "D. Aaron Sawyer" <aaron@110.net> - 2015-09-16 14:22 -0300
Re: What's the best hashing function? fir <profesor.fir@gmail.com> - 2015-09-16 10:59 -0700
Re: What's the best hashing function? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-09-16 19:44 +0100
Re: What's the best hashing function? fir <profesor.fir@gmail.com> - 2015-09-16 12:32 -0700
Re: What's the best hashing function? Bartc <bc@freeuk.com> - 2015-09-16 20:40 +0100
Re: What's the best hashing function? Keith Thompson <kst-u@mib.org> - 2015-09-16 13:11 -0700
Re: What's the best hashing function? "James Harris" <james.harris.1@gmail.com> - 2015-09-16 21:16 +0100
Re: What's the best hashing function? fir <profesor.fir@gmail.com> - 2015-09-16 13:47 -0700
Re: What's the best hashing function? fir <profesor.fir@gmail.com> - 2015-09-16 14:14 -0700
Re: What's the best hashing function? Robert Wessel <robertwessel2@yahoo.com> - 2015-09-16 18:08 -0500
Re: What's the best hashing function? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-09-17 00:13 +0100
Re: What's the best hashing function? fir <profesor.fir@gmail.com> - 2015-09-20 01:13 -0700
Re: What's the best hashing function? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-09-16 13:10 -0700
Re: What's the best hashing function? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-09-16 22:17 +0100
Re: What's the best hashing function? fir <profesor.fir@gmail.com> - 2015-09-16 14:33 -0700
Re: What's the best hashing function? fir <profesor.fir@gmail.com> - 2015-09-16 14:48 -0700
Re: What's the best hashing function? fir <profesor.fir@gmail.com> - 2015-09-16 14:58 -0700
Re: What's the best hashing function? Robert Wessel <robertwessel2@yahoo.com> - 2015-09-16 18:13 -0500
Re: What's the best hashing function? supercat@casperkitty.com - 2015-09-16 16:29 -0700
Re: What's the best hashing function? David Brown <david.brown@hesbynett.no> - 2015-09-17 10:17 +0200
Re: What's the best hashing function? Keith Thompson <kst-u@mib.org> - 2015-09-17 08:53 -0700
Re: What's the best hashing function? supercat@casperkitty.com - 2015-09-17 11:29 -0700
Re: What's the best hashing function? David Brown <david.brown@hesbynett.no> - 2015-09-18 10:07 +0200
Re: What's the best hashing function? Richard Heathfield <rjh@cpax.org.uk> - 2015-09-18 09:20 +0100
Re: What's the best hashing function? supercat@casperkitty.com - 2015-09-18 09:25 -0700
Re: What's the best hashing function? David Brown <david.brown@hesbynett.no> - 2015-09-18 19:45 +0200
Re: What's the best hashing function? supercat@casperkitty.com - 2015-09-18 11:47 -0700
Re: What's the best hashing function? David Brown <david.brown@hesbynett.no> - 2015-09-18 21:49 +0200
Re: What's the best hashing function? supercat@casperkitty.com - 2015-09-18 14:50 -0700
Re: What's the best hashing function? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-09-19 00:23 -0700
Re: What's the best hashing function? David Brown <david.brown@hesbynett.no> - 2015-09-19 11:13 +0200
Re: What's the best hashing function? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-09-19 11:03 +0100
Re: What's the best hashing function? David Brown <david.brown@hesbynett.no> - 2015-09-19 12:38 +0200
Re: What's the best hashing function? supercat@casperkitty.com - 2015-09-21 11:29 -0700
Re: What's the best hashing function? David Brown <david.brown@hesbynett.no> - 2015-09-22 10:23 +0200
Re: What's the best hashing function? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-09-22 02:31 -0700
Re: What's the best hashing function? supercat@casperkitty.com - 2015-09-22 11:28 -0700
Re: What's the best hashing function? supercat@casperkitty.com - 2015-09-22 11:18 -0700
Re: What's the best hashing function? David Brown <david.brown@hesbynett.no> - 2015-09-17 10:24 +0200
Re: What's the best hashing function? fir <profesor.fir@gmail.com> - 2015-09-17 01:48 -0700
Re: What's the best hashing function? fir <profesor.fir@gmail.com> - 2015-09-17 01:56 -0700
Re: What's the best hashing function? fir <profesor.fir@gmail.com> - 2015-09-17 02:09 -0700
Re: What's the best hashing function? Keith Thompson <kst-u@mib.org> - 2015-09-16 14:49 -0700
Re: What's the best hashing function? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-09-16 21:56 +0000
Re: What's the best hashing function? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-09-16 23:37 +0100
Re: What's the best hashing function? supercat@casperkitty.com - 2015-09-16 13:02 -0700
Re: What's the best hashing function? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-09-16 21:57 +0100
Re: What's the best hashing function? supercat@casperkitty.com - 2015-09-16 14:16 -0700
Re: What's the best hashing function? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-09-16 21:57 +0000
Re: What's the best hashing function? supercat@casperkitty.com - 2015-09-16 16:20 -0700
csiph-web