Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 60569 invoked from network); 11 Mar 2009 14:05:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Mar 2009 14:05:30 -0000 Received: (qmail 31940 invoked by uid 500); 11 Mar 2009 14:05:22 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 31918 invoked by uid 500); 11 Mar 2009 14:05:22 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 31907 invoked by uid 99); 11 Mar 2009 14:05:22 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Mar 2009 07:05:22 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of yseeley@gmail.com designates 74.125.92.24 as permitted sender) Received: from [74.125.92.24] (HELO qw-out-2122.google.com) (74.125.92.24) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Mar 2009 14:05:14 +0000 Received: by qw-out-2122.google.com with SMTP id 5so9143qwi.53 for ; Wed, 11 Mar 2009 07:04:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:reply-to:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:content-type:content-transfer-encoding; bh=KVV6N5rulYacUKuaC8p/b0Ubh46npIhgJP/IBGwxLas=; b=k2n52P+Qp2+z3LMsDssIaY8KwdujWLdkIrEO+FwP2IG+BEn6HXH1rrhFUrsn1Q+ekx DdaWAqd+KNl4w/XOrAgpU/gzew3GcwqMzoNOq4BaWQlKqER30tfSFFkT/HOQP/hA361z UazzMaQ5QTP+91WFuzzWaAwZ0QgA/KHBaIPWA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:reply-to:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=ZJ0p8GrfWOo9i56as1RnA3zjqfyzqN4gQim3JN2ANt4na26mHonits9aKXavSNe7ac 08hLNsQv/U1wnK3TPrplbLVfATM4cjkSUJYW45v6YnQL+3OwG3MPPu/RLl+KBObOWeM8 37bR1mfQlM0RI9L+6hS/PnkmJysCiR02zAN0Q= MIME-Version: 1.0 Sender: yseeley@gmail.com Reply-To: yonik@lucidimagination.com Received: by 10.229.97.202 with SMTP id m10mr4718999qcn.77.1236780285676; Wed, 11 Mar 2009 07:04:45 -0700 (PDT) In-Reply-To: <68959F25CDEBCB4F917D5A253291D73E0D8BAB7209@BLRKECMBX06.ad.infosys.com> References: <68959F25CDEBCB4F917D5A253291D73E0D8BAB7209@BLRKECMBX06.ad.infosys.com> Date: Wed, 11 Mar 2009 10:04:45 -0400 X-Google-Sender-Auth: f9c8fa5e489721ce Message-ID: Subject: Re: Integer2String Covnersation From: Yonik Seeley To: java-user@lucene.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On Wed, Mar 11, 2009 at 9:54 AM, Allahbaksh Mohammedali Asadullah wrote: > Hi all, > Can any one explain How function integer2String works. > > =A0public static int int2sortableStr(int val, char[] out, int offset) { > > =A0 =A0val +=3D Integer.MIN_VALUE; This maps MIN_VALUE to 0 and MAX_VALUE to 0xffffffff, making the bits sort lexicographically the same as the full integer range. It's the same as flipping the sign bit. > =A0 =A0out[offset++] =3D (char)(val >>> 24); > =A0 =A0out[offset++] =3D (char)((val >>> 12) & 0x0fff); > =A0 =A0out[offset++] =3D (char)(val & 0x0fff); This chops up the bits to fit in char sized pieces to make a string, avoiding invalid character ranges. -Yonik http://www.lucidimagination.com --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org