Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 10509632304 for ; Fri, 25 Jun 2010 19:53:16 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 26201-10 for ; Fri, 25 Jun 2010 22:53:04 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-vw0-f46.google.com (mail-vw0-f46.google.com [209.85.212.46]) by mail.postgresql.org (Postfix) with ESMTP id CCD016327F0 for ; Fri, 25 Jun 2010 19:53:05 -0300 (ADT) Received: by vws9 with SMTP id 9so4473948vws.19 for ; Fri, 25 Jun 2010 15:53:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:x-enigmail-version:content-type :content-transfer-encoding; bh=yRX25Z14E9A7yGOTQGkdLI4wvSBz1bcQKSH8ESnHfFw=; b=URXUr60UqQ71/rE4tgpNNGVu+OQTs37CBJ4q+bx6m/5GlK75WSX7mziknpqMkjw+c4 7UZSNSgvFl8xYIaCBVhgm8bm/wP+4CawPhfFhHTrfksddmpMiRvxtX+BbFIcMuYI6zxJ BMyeIb1OXxeN3uyiJ0I0OWd2TorCwgaJvmumY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :x-enigmail-version:content-type:content-transfer-encoding; b=ebXr+zYNnXJC7+x76CflSo1lD/gR2hYyWrztqbHCSta9xWynqiFprw7rscm6Luhd+N lGNKcN33kqM92bRgnXtT6je+5NEZMwt3pezVB1ABpvV2M23cGYB+qbJi/uhOOeGYoqzh b4AUhL77j3ylHfNZZ2ifOqjIUmzmWZK/VNs10= Received: by 10.229.233.17 with SMTP id jw17mr939544qcb.219.1277506384448; Fri, 25 Jun 2010 15:53:04 -0700 (PDT) Received: from [192.168.1.100] (207-237-122-16.c3-0.wsd-ubr1.qens-wsd.ny.cable.rcn.com [207.237.122.16]) by mx.google.com with ESMTPS id q31sm10945321qcq.44.2010.06.25.15.53.02 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 25 Jun 2010 15:53:03 -0700 (PDT) Message-ID: <4C25334D.4040805@gmail.com> Date: Fri, 25 Jun 2010 18:53:01 -0400 From: Lee Hachadoorian User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100423 Thunderbird/3.0.4 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Round integer division X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.8 tagged_above=-5 required=5 tests=BAYES_50=0.8, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201006/96 X-Sequence-Number: 34287 Is it documented anywhere that floating-point numbers round "scientifically", that is 0.5 rounds to the nearest even number? Compare: SELECT round(2.5::real), round(2.5::numeric), round(3.5::real), round(3.5::numeric); generates 2 | 3 | 4 | 4 I stumbled across this when I was trying to use round(a::real/b::real) to generate a rounded result to dividing integers, and noticed sometimes 0.5 was truncated and sometimes it was rounded up. Couldn't find anything about this in the archives or the data type documentation. Is there something obvious that I'm I missing? Thanks, -- Lee Hachadoorian PhD Student, Geography Program in Earth & Environmental Sciences CUNY Graduate Center