X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D3801D1B1D5 for ; Fri, 9 Jul 2004 18:33:46 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 12405-04 for ; Fri, 9 Jul 2004 21:33:47 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id 2AED7D1B1D1 for ; Fri, 9 Jul 2004 18:33:44 -0300 (ADT) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=opencloud.com) by yass.opencloud.co.nz with asmtp (Exim 3.35 #1 (Debian)) id 1Bj2zy-00077G-00; Sat, 10 Jul 2004 09:33:39 +1200 Message-ID: <40EF0F10.9040409@opencloud.com> Date: Sat, 10 Jul 2004 09:33:04 +1200 From: Oliver Jowett User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pg@fastcrypt.com Cc: Kris Jurka , "pgsql-jdbc@postgresql.org" Subject: Re: getXXX methods References: <1088795907.1536.118.camel@localhost.localdomain> <1089145387.1506.65.camel@localhost.localdomain> <1089154614.1508.70.camel@localhost.localdomain> <40EB385F.9030704@opencloud.com> <1089162095.1508.173.camel@localhost.localdomain> <40EB4D85.6080100@opencloud.com> <40EB5683.90301@opencloud.com> <1089230030.1506.226.camel@localhost.localdomain> <1089288683.1506.235.camel@localhost.localdomain> <1089387924.1506.287.camel@localhost.localdomain> In-Reply-To: <1089387924.1506.287.camel@localhost.localdomain> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/76 X-Sequence-Number: 10460 Dave Cramer wrote: > Well, I have an interesting problem... > > Detecting that a value is greater than MaxLong? > > If I parse it using Double.parseDouble, and it is greater than LongMax > by 1 or so, the value ends up actually being less due to rounding ? > > Any suggestions? The problem is that you're going via a double, you're going to lose precision there regardless of what you do (you don't have 64 bits of mantissa+sign to play with). If you want to retain precision, don't use a double as your intermediate value. Perhaps extract everything before the first '.' and use parseLong? That will truncate rather than round the value though. I don't like the whole idea of silently losing data anyway.. -O