X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A28B4D1B550 for ; Wed, 29 Oct 2003 00:15:50 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 95692-05 for ; Tue, 28 Oct 2003 20:15:22 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id A5148D1B50F for ; Tue, 28 Oct 2003 20:15:19 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id h9T0FJNu075398 for ; Wed, 29 Oct 2003 00:15:19 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h9T09wwU074493 for pgsql-sql@postgresql.org; Wed, 29 Oct 2003 00:09:58 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.sql Subject: Re: numeric and float converts to int differently? Date: Tue, 28 Oct 2003 18:11:13 -0500 Organization: Hub.Org Networking Services Lines: 21 Message-ID: <60u15tklf2.fsf@dev6.int.libertyrms.info> References: <072c01c39d65$65f83950$0403a8c0@fejleszt4> <20031028154536.GA29427@it.is.rice.edu> <074b01c39d72$6f512f90$0403a8c0@fejleszt4> <87brs1gr4y.fsf@stark.dyndns.tv> <0acb01c39d90$6d9d9080$0403a8c0@fejleszt4> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@news.hub.org User-Agent: Gnus/5.1003 (Gnus v5.10.3) XEmacs/21.4 (Reasonable Discussion, linux) Cancel-Lock: sha1:B2OovkqVBr7u+hKRzF6fThOQO4Q= To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/373 X-Sequence-Number: 15773 surrano@mailbox.hu (SZUCS Gábor) writes: > As Tom pointed out, it isn't a floating point failure -- it is how rounding > float is implemented. I assume anything with less than 15 digits can be > exactly represented as float. No, "decimal" fractions cannot ever be exactly represented in floating point because since they use powers of two, you wind up with repeated fractions. 1/3 is approximately 0.3333333, but you cannot present that exactly in decimal. In the very same way, 1/10 is approximately equal to 0.001001001001001001001001001001 (as a binary 'fraction'); the '001' part is a repeating group, and wherever you terminate it, you lose exactness. -- (reverse (concatenate 'string "ofni.smrytrebil" "@" "enworbbc")) Christopher Browne (416) 646 3304 x124 (land)