From owner-freebsd-questions@FreeBSD.ORG Fri Dec 3 08:53:07 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 704FC16A4CE for ; Fri, 3 Dec 2004 08:53:07 +0000 (GMT) Received: from mr.tuwien.ac.at (mr2-n.kom.tuwien.ac.at [128.131.2.110]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7D71D43D46 for ; Fri, 3 Dec 2004 08:53:06 +0000 (GMT) (envelope-from e0025265@student.tuwien.ac.at) Received: from webmail.zserv.tuwien.ac.at (lps.ben.tuwien.ac.at [193.170.74.11]) by mr.tuwien.ac.at (8.12.10/8.12.8) with SMTP id iB38r2Ew014151 for ; Fri, 3 Dec 2004 09:53:03 +0100 (MET) MIME-Version: 1.0 X-Mailer: V-webmail 1.5.1 ( http://www.v-webmail.co.uk/ ) Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-ID: Date: Fri, 3 Dec 2004 09:53:02 +0100 From: "Florian Hengstberger" To: FreeBSD mailinglist X-Vwebmail-Auth: e0025265@stud3.tuwien.ac.at X-Virus-Scanned: by amavisd-milter (http://amavis.org/) Subject: Floating Point Arithmetic X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Dec 2004 08:53:07 -0000 Hi! I tried to figure out the capability of double: so I calculated d=2**n (with a for-loop) increasing n step by step. Of course I get a floating point exception when d is bigger than 10**308. But what makes me wondering is the fact that printing printf("%lf",d) gives me the full range of numbers! Calculating 2**1000 and I got the correct number with all (!!) digits. (I cross-checked the digits with python.) This is unexpected because sizeof(double) on my machine is 8, and so I thought that the limit for the correct representation is 2**(8*8). (Actually the limit should be - meeting the IEEE standard - 2**52, the space reserved for representing the fraction of a floating point number.) Anyway I can calculate 2**n, with n up to 1023 exact. Why is this??? Thanks Florian PS: I even had a look at the assembly code, for printf the %lf and than twice 32bit a pushed on the stack before calling printf. Still not enough memory to represent 2**1000!