Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hRfJN-0007FU-1G for pgsql-bugs@arkaria.postgresql.org; Fri, 17 May 2019 16:02:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hRfJK-0008Jm-T1 for pgsql-bugs@arkaria.postgresql.org; Fri, 17 May 2019 16:02:18 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hRfJK-0008JC-I6 for pgsql-bugs@lists.postgresql.org; Fri, 17 May 2019 16:02:18 +0000 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hRfJH-0000co-6t for pgsql-bugs@lists.postgresql.org; Fri, 17 May 2019 16:02:16 +0000 Received: by mail-qt1-x841.google.com with SMTP id z19so8496555qtz.13 for ; Fri, 17 May 2019 09:02:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=3GfgfkwQtL3KAM/s0VAk8cnMwRiwcyc/U/7qvqElFuc=; b=TLQLliGplX31P1ft0UmWigioSDy508Lh3FJ9ui0eykQlKk/gcvcnCHqifDqM0IZ7XI C3go9NaQHTWC0wuSoBMOtNkzZPK5gtCA7UfM8XIiLzXuDq1nag8xa7iHpE9IksYPELQR JzK7UcRcWe0V/zunEbw0mh2PhRXH78wGWrXZhyT0wG7ipzlHiFwDTvGG4HbzWJn2P5zT rD0bJicdaDE2VM7x92wjbv+c+JMiIZniGkw2WHXFRe1SqnB1jdfCbMGe8XH+TS5BORhN NC3dCV//MiC625XXMN8G/p5zfKDnPKrANcidAPxd6wlrRejImQnqR+EVx7eHhBZBlWgd C/eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=3GfgfkwQtL3KAM/s0VAk8cnMwRiwcyc/U/7qvqElFuc=; b=ighOrZhTX9Smu7RpEdzZWcjtht/j1Afb+1fsPrsnR5S8yK2yAw3jcTCXR88auqMH/C FdSeKF5LXVuyvfOzt17oRYMiCw4GShFUQaZmTXZcNMcLvT5JKZIauZe3HRNxUiSIFjkW 3KomPAsIN+vVdvahlg+w+CpEPNSr55tkLCOvJcVLoFHLFb+ntDBAS2tnVyszgkQIyzzY LPKp1Y9f1NgQhg/GhiQcxrsBD8g8s510PgzQWDai4C2ulOXm8o+SmyCwOMqS2r/zTTP0 7YnUxS9f33JcslRJZnjXg3Qe8vNLm6VTBevtCnq8ne18E8m/ECiPm1pCzPRZijIoVQPk Jwrg== X-Gm-Message-State: APjAAAVqfackUW1pYuLIZw/5uM9/jxjcJRodT/iIEsm+1SnOAhnPy4Gv vtMdM+AWknoczZMfY4HvjAdS/A== X-Google-Smtp-Source: APXvYqyUSxUTiI0uAOVJ3rD5tI+DGK9umpIMYnf1Xj8UGA6MinM/6zYZ2opoxfgPssWTvSMoHMwijw== X-Received: by 2002:ac8:2cbc:: with SMTP id 57mr26740402qtw.222.1558108934458; Fri, 17 May 2019 09:02:14 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([179.56.48.227]) by smtp.gmail.com with ESMTPSA id d58sm7111559qtb.11.2019.05.17.09.02.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 17 May 2019 09:02:13 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 463CB120617; Fri, 17 May 2019 12:02:11 -0400 (-04) Date: Fri, 17 May 2019 12:02:11 -0400 From: Alvaro Herrera To: kaleb.akalework@asg.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15812: Select statement of a very big number, with a division operator seems to round up. Message-ID: <20190517160211.GA27103@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <15812-adda7f0f3359803c@postgresql.org> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-May-17, PG Bug reporting form wrote: > create table test_table > ( > REQUEST_UUID varchar(50) not null, > BIG_NUM numeric(20,0) not null > ); > > INSERT INTO test_table (REQUEST_UUID, BIG_NUM) values ('TEST', > 3691635539999999999); > INSERT INTO test_table (REQUEST_UUID, BIG_NUM) values('TEST', > 3691635530099999999); > INSERT INTO test_table (REQUEST_UUID, BIG_NUM) values('TEST', > 3691635530999999999); > > SELECT BIG_NUM, FLOOR(BIG_NUM/10000000000), BIG_NUM/10000000000 from > test_table; Well, your column definition has room for zero decimal places, so I'm not sure this result is all that surprising. Maybe you should cast the column to one that has a few decimal places, say select bit_num::numeric(30,10) / 10000000000 from test_table; and see whether that helps your case. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services