15,671,316 members

# The Weird and The Wonderful

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 Re: Does anyone recognized this "decryption" algorithm? PIEBALDconsult24-Nov-21 1:53 PIEBALDconsult 24-Nov-21 1:53
 Re: Does anyone recognized this "decryption" algorithm? Eddy Vluggen26-Nov-21 10:26 Eddy Vluggen 26-Nov-21 10:26
 Re: Does anyone recognized this "decryption" algorithm? Philippe Verdy26-Nov-21 3:32 Philippe Verdy 26-Nov-21 3:32
 Re: Does anyone recognized this "decryption" algorithm? harold aptroot26-Nov-21 5:08 harold aptroot 26-Nov-21 5:08
 Re: Does anyone recognized this "decryption" algorithm? PIEBALDconsult26-Nov-21 10:00 PIEBALDconsult 26-Nov-21 10:00
 Re: Does anyone recognized this "decryption" algorithm? harold aptroot26-Nov-21 10:27 harold aptroot 26-Nov-21 10:27
 Re: Does anyone recognized this "decryption" algorithm? brian012528-Nov-21 16:53 brian0125 28-Nov-21 16:53
 Re: Does anyone recognized this "decryption" algorithm? Philippe Verdy8-Sep-22 20:14 Philippe Verdy 8-Sep-22 20:14
 Just consider if your table size is a multiple of 5... The hash value itself, even if it's a power of 2, is not sufficient: the multiplier msut be a coprime of the integer size (a power of 2, so the multiplier must not be even) cannot AND of ANY hash table size (which can be quite arbitrary integer, not necessarily a power of 2). That's why using primes is always better. And why usually, the factor used in Fast Knuth Algorithm is a prime near the value of sqrt(2^(N-1)), for a generated hash value in [0, 2^N), i.e. the largest prime near below 2^(N/2); for a 32-bit hash value this means using the prime factor just below 65536, like 65521 or 65537 (but the 1st is better as the number of bits 1 or 0 are more equally balanced); but if your hash value will index strings of 1-byte characters or variable-length array of bytes (which are 4 times smaller in bitsize than the hash value), you'll use a factor near 2^4, rounded up to take into account for short strings, so you'll use the factor 17 (which contains 2 bits set to 1 and 2 bits set to 0: it is balanced and has good randomization properties): using a factor of 17 is also very fast to compute even if you don't have hardware multiplier in the instruction set of your ALU, or even if you don't have hardware shifts (it can be computed noly with 5 additions in that case, and a single pair of CPU registers; but this use is now extremely rare except in very cheap 8-bit controlers).
 Re: Does anyone recognized this "decryption" algorithm? harold aptroot9-Sep-22 1:01 harold aptroot 9-Sep-22 1:01
 Re: Does anyone recognized this "decryption" algorithm? Philippe Verdy9-Sep-22 1:31 Philippe Verdy 9-Sep-22 1:31
 Re: Does anyone recognized this "decryption" algorithm? brian012528-Nov-21 16:54 brian0125 28-Nov-21 16:54
 Re: Does anyone recognized this "decryption" algorithm? Philippe Verdy8-Sep-22 20:37 Philippe Verdy 8-Sep-22 20:37
 Re: Does anyone recognized this "decryption" algorithm? brian012528-Nov-21 16:31 brian0125 28-Nov-21 16:31
 RA8875 has ridiculous registers honey the codewitch16-Nov-21 1:31 honey the codewitch 16-Nov-21 1:31
 Re: RA8875 has ridiculous registers Greg Utas16-Nov-21 1:39 Greg Utas 16-Nov-21 1:39
 Re: RA8875 has ridiculous registers honey the codewitch16-Nov-21 1:42 honey the codewitch 16-Nov-21 1:42
 Re: RA8875 has ridiculous registers Jörgen Andersson23-Nov-21 3:00 Jörgen Andersson 23-Nov-21 3:00
 Re: RA8875 has ridiculous registers den2k8816-Nov-21 1:45 den2k88 16-Nov-21 1:45
 Re: RA8875 has ridiculous registers honey the codewitch16-Nov-21 4:13 honey the codewitch 16-Nov-21 4:13
 Re: RA8875 has ridiculous registers PIEBALDconsult16-Nov-21 4:10 PIEBALDconsult 16-Nov-21 4:10
 Re: RA8875 has ridiculous registers honey the codewitch16-Nov-21 4:13 honey the codewitch 16-Nov-21 4:13
 Re: RA8875 has ridiculous registers Fueled By Decaff16-Nov-21 4:18 Fueled By Decaff 16-Nov-21 4:18
 Re: RA8875 has ridiculous registers honey the codewitch16-Nov-21 4:19 honey the codewitch 16-Nov-21 4:19
 Re: RA8875 has ridiculous registers Fueled By Decaff16-Nov-21 4:48 Fueled By Decaff 16-Nov-21 4:48
 Re: RA8875 has ridiculous registers honey the codewitch16-Nov-21 5:07 honey the codewitch 16-Nov-21 5:07
 Last Visit: 31-Dec-99 18:00     Last Update: 8-Jun-23 18:12 Refresh ᐊ Prev1...15161718192021222324 Next ᐅ