Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TEcYY-0005rO-DX for pgsql-admin@postgresql.org; Thu, 20 Sep 2012 08:56:22 +0000 Received: from blu0-omc1-s27.blu0.hotmail.com ([65.55.116.38]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TEcYW-0000NO-6j for pgsql-admin@postgresql.org; Thu, 20 Sep 2012 08:56:21 +0000 Received: from BLU0-SMTP48 ([65.55.116.9]) by blu0-omc1-s27.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 20 Sep 2012 01:56:16 -0700 X-Originating-IP: [61.170.253.133] X-EIP: [jv1D+Yl/zfMGbOvJ7Qmuo11JKLFQ9fcA] X-Originating-Email: [liuhaifeng@live.com] Message-ID: Received: from [172.16.224.42] ([61.170.253.133]) by BLU0-SMTP48.blu0.hotmail.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Thu, 20 Sep 2012 01:56:08 -0700 From: Haifeng Liu Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: how to allow integer overflow for calculating hash code of a string? Date: Thu, 20 Sep 2012 16:55:46 +0800 To: "pgsql-admin@postgresql.org" MIME-Version: 1.0 (Mac OS X Mail 6.1 \(1498\)) X-Mailer: Apple Mail (2.1498) X-OriginalArrivalTime: 20 Sep 2012 08:56:12.0317 (UTC) FILETIME=[C8D1BCD0:01CD970D] X-Pg-Spam-Score: 0.8 (/) X-Archive-Number: 201209/112 X-Sequence-Number: 40053 I want to write a hash function which acts as String.hashCode() in java: = hash =3D hash * 31 + s.charAt(i)... but I got integer out of range = error. How can I avoid this? I saw java do not care overflow of int, it = just make the result negative.=