From ryhong@hotmail.com Sat Jan 4 23:57:17 2003 Received: from hotmail.com (f213.law8.hotmail.com [216.33.241.213]) by digital.linux.org.au (8.12.6/8.12.6/Debian-8) with ESMTP id h04Fv4tr006527 for ; Sat, 4 Jan 2003 23:57:17 +0800 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Sat, 4 Jan 2003 07:58:24 -0800 Received: from 211.98.44.66 by lw8fd.law8.hotmail.msn.com with HTTP; Sat, 04 Jan 2003 15:58:24 GMT X-Originating-IP: [211.98.44.66] From: "Ray hong" To: tuxcpprogramming@lists.linux.org.au Mime-Version: 1.0 Content-Type: text/html Message-ID: X-OriginalArrivalTime: 04 Jan 2003 15:58:24.0704 (UTC) FILETIME=[1CE1FC00:01C2B40A] Subject: [LC++]float, double, or long double? Sender: tuxcpprogramming-admin@lists.linux.org.au Errors-To: tuxcpprogramming-admin@lists.linux.org.au X-BeenThere: tuxcpprogramming@lists.linux.org.au X-Mailman-Version: 2.0.13 Precedence: bulk Reply-To: tuxcpprogramming@lists.linux.org.au List-Unsubscribe: , List-Id: The Linux C++ Programming List List-Post: List-Help: List-Subscribe: , List-Archive: Date: Sat Jan 4 23:58:02 2003 X-Original-Date: Sat, 04 Jan 2003 15:58:24 +0000

 Dear Sir or Madam,

 

How are you doing?

 

As far as I know, there are the: real (single precision), double (precision), and the complex (precision)

in the Fortran. While in the C or C++, there are also the float (single precision) and the double (precision).

Could you tell me whether there is the better (more accurate) one, something like the "long double"?

 

Currently, I encountered difficulties in the numerical computation. The best way to overcome it is to use

the more accurate data structure. If not possible, I maybe have to the Fortran.

 

Looking forward to hearing from you.

 

Best regards.

 

Ray



The new MSN 8: smart spam protection and 2 months FREE*. From David.W.Spencer@oracle.com Mon Jan 6 23:02:33 2003 Received: from inet-mail3.oracle.com (inet-mail3.oracle.com [148.87.2.203]) by digital.linux.org.au (8.12.6/8.12.6/Debian-8) with ESMTP id h06F2Ftr005504 for ; Mon, 6 Jan 2003 23:02:32 +0800 Received: from inet-mail3.oracle.com (localhost [127.0.0.1]) by inet-mail3.oracle.com (Switch-2.2.3/Switch-2.2.3) with ESMTP id h06F3vw19186 for ; Mon, 6 Jan 2003 07:03:57 -0800 (PST) Received: from rgmgw1.us.oracle.com (rgmgw1.us.oracle.com [138.1.191.10]) by inet-mail3.oracle.com (Switch-2.2.3/Switch-2.2.3) with ESMTP id h06F3uL19173 for ; Mon, 6 Jan 2003 07:03:56 -0800 (PST) Received: from rgmgw1.us.oracle.com (localhost [127.0.0.1]) by rgmgw1.us.oracle.com (Switch-2.1.3/Switch-2.1.0) with ESMTP id h06F3tT11416 for ; Mon, 6 Jan 2003 08:03:55 -0700 (MST) Received: from oracle.com (DHCP-TVP550-151-166.uk.oracle.com [138.3.151.166]) by rgmgw1.us.oracle.com (Switch-2.1.3/Switch-2.1.0) with ESMTP id h06F3m311243 for ; Mon, 6 Jan 2003 08:03:50 -0700 (MST) Message-ID: <3E199AD1.10702@oracle.com> From: David Spencer Organization: Oracle Corporation User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en MIME-Version: 1.0 To: tuxcpprogramming@lists.linux.org.au Subject: Re: [LC++]float, double, or long double? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: tuxcpprogramming-admin@lists.linux.org.au Errors-To: tuxcpprogramming-admin@lists.linux.org.au X-BeenThere: tuxcpprogramming@lists.linux.org.au X-Mailman-Version: 2.0.13 Precedence: bulk Reply-To: tuxcpprogramming@lists.linux.org.au List-Unsubscribe: , List-Id: The Linux C++ Programming List List-Post: List-Help: List-Subscribe: , List-Archive: Date: Mon Jan 6 23:03:01 2003 X-Original-Date: Mon, 06 Jan 2003 15:03:45 +0000 Ray hong wrote: > Dear Sir or Madam, > > > > How are you doing? > > > I was ok until that greeting - what am I, your bank manager? :-) > As far as I know, there are the: real (single precision), double > (precision), and the complex (precision) > > in the Fortran. While in the C or C++, there are also the float > (single precision) and the double (precision). > > Could you tell me whether there is the better (more accurate) one, > something like the "long double"? > The most accurate are the integral forms - int, long, long long etc. All floating point representations are approximate. double stores more digits than float, and I think there's a long double as well, but there is no complex type in C (but you can use two doubles.) > > > Currently, I encountered difficulties in the numerical computation. > The best way to overcome it is to use > > the more accurate data structure. If not possible, I maybe have to the > Fortran. > What difficulties precisely? Stuff like 1.9 being represented as 1.8999999999999947451253 for example? Fortran won't fix this kind of problem though (unless its maths libraries function significantly differently from C's) Dave. From lloyd@acm.jhu.edu Tue Jan 7 00:54:38 2003 Received: from centaur.acm.jhu.edu (IDENT:postfix@centaur.acm.jhu.edu [128.220.223.65]) by digital.linux.org.au (8.12.6/8.12.6/Debian-8) with ESMTP id h06GsNtr006380 for ; Tue, 7 Jan 2003 00:54:38 +0800 Received: by centaur.acm.jhu.edu (Postfix, from userid 528) id 4E86B13E97; Mon, 6 Jan 2003 11:56:10 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by centaur.acm.jhu.edu (Postfix) with ESMTP id 4DFB037DF4 for ; Mon, 6 Jan 2003 11:56:10 -0500 (EST) From: Jack Lloyd To: Subject: Re: [LC++]float, double, or long double? In-Reply-To: <3E199AD1.10702@oracle.com> Message-ID: X-GPG-Key-ID: 4DCDF398 X-GPG-Key-Fingerprint: 2DD2 95F9 C7E3 A15E AF29 80E1 D6A9 A5B9 4DCD F398 X-Red-Robot-Approved: CRUSH ALL HU-MANS! Organization: JHU ACM/CS/SRL MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: tuxcpprogramming-admin@lists.linux.org.au Errors-To: tuxcpprogramming-admin@lists.linux.org.au X-BeenThere: tuxcpprogramming@lists.linux.org.au X-Mailman-Version: 2.0.13 Precedence: bulk Reply-To: tuxcpprogramming@lists.linux.org.au List-Unsubscribe: , List-Id: The Linux C++ Programming List List-Post: List-Help: List-Subscribe: , List-Archive: Date: Tue Jan 7 00:55:01 2003 X-Original-Date: Mon, 6 Jan 2003 11:56:10 -0500 (EST) On Mon, 6 Jan 2003, David Spencer wrote: > The most accurate are the integral forms - int, long, long long etc. > All floating point representations are approximate. double stores more > digits than float, and I think there's a long double as well, but there > is no complex type in C (but you can use two doubles.) IIRC there is a complex type in C99, which GCC does support. In addition, since this was address to the C++ list, I'll add that there is a complex class in ISO C++. On many machines, long double is the same size as double, but on some FPUs you may get a few extra bits. The x87 is like that, though there are other problems there (80 bits internally, 64 bits outside the FPU... rather strange). Also SPARC supports a 128 bit long double, but no hardware supports it so it just traps into software routines. The original poster could also try GMP, which, I think, supports infinite precision floating point. Of course it's much slower since it's all done in software instead of the FPU. -Jack From ryhong at hotmail.com Sat Jan 4 23:58:02 2003 From: ryhong at hotmail.com (Ray hong) Date: Sat Jan 4 23:58:02 2003 Subject: [LC++]float, double, or long double? Message-ID: An HTML attachment was scrubbed... URL: http://lists.linux.org.au/pipermail/tuxcpprogramming/attachments/20030104/e0f9bd78/attachment.htm From David.W.Spencer at oracle.com Mon Jan 6 23:03:01 2003 From: David.W.Spencer at oracle.com (David Spencer) Date: Mon Jan 6 23:03:01 2003 Subject: [LC++]float, double, or long double? In-Reply-To: References: Message-ID: <3E199AD1.10702@oracle.com> Ray hong wrote: > Dear Sir or Madam, > > > > How are you doing? > > > I was ok until that greeting - what am I, your bank manager? :-) > As far as I know, there are the: real (single precision), double > (precision), and the complex (precision) > > in the Fortran. While in the C or C++, there are also the float > (single precision) and the double (precision). > > Could you tell me whether there is the better (more accurate) one, > something like the "long double"? > The most accurate are the integral forms - int, long, long long etc. All floating point representations are approximate. double stores more digits than float, and I think there's a long double as well, but there is no complex type in C (but you can use two doubles.) > > > Currently, I encountered difficulties in the numerical computation. > The best way to overcome it is to use > > the more accurate data structure. If not possible, I maybe have to the > Fortran. > What difficulties precisely? Stuff like 1.9 being represented as 1.8999999999999947451253 for example? Fortran won't fix this kind of problem though (unless its maths libraries function significantly differently from C's) Dave. From lloyd at acm.jhu.edu Tue Jan 7 00:55:01 2003 From: lloyd at acm.jhu.edu (Jack Lloyd) Date: Tue Jan 7 00:55:01 2003 Subject: [LC++]float, double, or long double? In-Reply-To: <3E199AD1.10702@oracle.com> Message-ID: On Mon, 6 Jan 2003, David Spencer wrote: > The most accurate are the integral forms - int, long, long long etc. > All floating point representations are approximate. double stores more > digits than float, and I think there's a long double as well, but there > is no complex type in C (but you can use two doubles.) IIRC there is a complex type in C99, which GCC does support. In addition, since this was address to the C++ list, I'll add that there is a complex class in ISO C++. On many machines, long double is the same size as double, but on some FPUs you may get a few extra bits. The x87 is like that, though there are other problems there (80 bits internally, 64 bits outside the FPU... rather strange). Also SPARC supports a 128 bit long double, but no hardware supports it so it just traps into software routines. The original poster could also try GMP, which, I think, supports infinite precision floating point. Of course it's much slower since it's all done in software instead of the FPU. -Jack