On 9 October 2011 14:35, Jörg Schaible <joerg.schai...@gmx.de> wrote: > Hi Sebb, > > sebb wrote: > >> On 7 October 2011 21:53, <simonetrip...@apache.org> wrote: >>> Author: simonetripodi >>> Date: Fri Oct 7 20:53:25 2011 >>> New Revision: 1180231 >>> >>> URL: http://svn.apache.org/viewvc?rev=1180231&view=rev >>> Log: >>> '4' is a magic number. >> >> Agreed. >> >>> Modified: >>> > commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryCompositeBinaryFunction.java >>> >>> Modified: >>> > commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryCompositeBinaryFunction.java >>> URL: >>> > http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryCompositeBinaryFunction.java?rev=1180231&r1=1180230&r2=1180231&view=diff >>> > ============================================================================== >>> --- >>> > commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryCompositeBinaryFunction.java >>> (original) +++ >>> > commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryCompositeBinaryFunction.java >>> Fri Oct 7 20:53:25 2011 @@ -48,6 +48,9 @@ public class >>> UnaryCompositeBinaryFunctio */ private static final long serialVersionUID >>> = 264219357293822629L; >>> >>> + /** Base hash integer used to shift hash. */ >>> + private static final int HASH_SHIFT = 4; >>> + >> >> We know what it is used for, but why choose 4 rather than 3 or 42 or 1? >> >> Is it arbitrary? If so, what is the possible range? >> If not arbitrary, why choose 4? > > Kidding? An int has 32 bits in Java. Shifting by 42 gives ... 0 :D
42 is the magic number in HHGTTG > So you should not use a very high number, because you will lose bits at the > upper end. What I am always wondering more, is why losing bits at all, > simply use the rolling shift operation: > > hash >>>= HASH_SHIFT; > [snip] > > - Jörg > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org