Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XkEOk-0002Zc-Nf for pgsql-sql@arkaria.postgresql.org; Fri, 31 Oct 2014 15:45:58 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XkEOk-0002Nx-6J for pgsql-sql@arkaria.postgresql.org; Fri, 31 Oct 2014 15:45:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XkEOi-0002Lk-Gg for pgsql-sql@postgresql.org; Fri, 31 Oct 2014 15:45:56 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XkEOe-0004Y8-5J for pgsql-sql@postgresql.org; Fri, 31 Oct 2014 15:45:55 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 0724E2077B for ; Fri, 31 Oct 2014 11:45:48 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute4.internal (MEProxy); Fri, 31 Oct 2014 11:45:49 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=aklaver.com; h= x-sasl-enc:message-id:date:from:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; s=mesmtp; bh=m3IiTB//tv3oiCd6mOmXCOUcAYE=; b=iqClCW6wwGVhNE0qW9 WXlLI1XRPDorjPT7+WSyFziW9vzoK6V2mlHQ4JDMv1NXHazI3YI890HCbYueEsOF 2VBOpZu+xe89dqQo75XMp4IKuRBzKEPhInmThYiVXszMhYdCC0l68nLDh0UJLtEX AEmuOiz1pmd6oKstBIxWv0P5s= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=x-sasl-enc:message-id:date:from :mime-version:to:subject:references:in-reply-to:content-type :content-transfer-encoding; s=smtpout; bh=m3IiTB//tv3oiCd6mOmXCO UcAYE=; b=saPohuTVhE5NUqdO+pvlwlXMDsoDj2HNK37bzpyD36xeo1rNMCNwJM Tg4qVXK5WHz5iCLwQCWENzt/WLaztOS9y8ibu7OV6tl0nF2bQ+TryI7+Gl4/+ZzP LzWaJW2H0m2HAubdrLGMNKF6jUWSAGuD0CGr9buhv/13XWrbDrbak= X-Sasl-enc: vYHgnAe8Siukjo/YH5knUjtCkgYPhNs5T+svjJ8t4ojO 1414770348 Received: from [192.168.1.5] (unknown [97.113.25.101]) by mail.messagingengine.com (Postfix) with ESMTPA id 81C11C0000A; Fri, 31 Oct 2014 11:45:48 -0400 (EDT) Message-ID: <5453AEAB.5020001@aklaver.com> Date: Fri, 31 Oct 2014 08:45:47 -0700 From: Adrian Klaver User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: =?UTF-8?B?RmlsaXAgUmVtYmlhxYJrb3dza2k=?= , Community PostgreSQL Subject: Re: INT8 / float casting question References: In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org On 10/31/2014 07:58 AM, Filip RembiaƂkowski wrote: > psql.bin (9.3.4, server 9.3.5) > Type "help" for help. > > dev=# select (2^63-1)::INT8; > ERROR: bigint out of range > > > > > > Does it HAVE to be so? No, figured it out: test=# select ((2^63-1)::numeric); numeric --------------------- 9223372036854780000 is rounding up. To get what you want: test=# select (2^63::numeric-1)::int8; int8 --------------------- 9223372036854775807 (1 row) > > > http://en.wikipedia.org/wiki/9223372036854775807 > > > > Thanks > Filip > > -- Adrian Klaver adrian.klaver@aklaver.com -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql