From 8692481599263302153
X-Google-Thread: f78e5,4ba9dcb1ae436e16
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news1.google.com!news2.google.com!proxad.net!proxad.net!194.159.246.34.MISMATCH!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull
From: AlbertoBarbati@libero.it (Alberto Barbati)
Newsgroups: comp.std.c++
Subject: Re: Pi, Euler Number, and perhaps other 'natural' constants?
Date: Wed, 28 Jul 2004 15:54:53 GMT
Organization: [Infostrada]
Lines: 32
Sender: mail2news@demon.net
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <P1JNc.15868$1V3.392640@twister2.libero.it>
References: <5cydnSisJNo4yJncRVn-sQ@speakeasy.net> <ce5ais$f50$1@news.inter.net.il> <mrvNc.3129$AY5.1919@newssvr21.news.prodigy.com>
NNTP-Posting-Host: news.news.demon.net
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.demon.co.uk 1091030101 27847 158.152.254.254 (28 Jul 2004 15:55:01 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Wed, 28 Jul 2004 15:55:01 +0000 (UTC)
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040514
X-Spam-Checker-Version: SpamAssassin 2.60-mulga_r1 (1.212-2003-09-23-exp) on 
	mulga.cs.mu.OZ.AU
X-Spam-Status: No, hits=-4.0 required=5.2 tests=AWL,BAYES_00 autolearn=ham 
	version=2.60-mulga_r1
X-Accept-Language: en, it
X-Virus-Scanned: by amavisd-new at libero.it
X-Path: comp-std-cpp-robomod!not-for-mail
X-Received: (from fjh@localhost)
	by mulga.cs.mu.OZ.AU (8.12.10+Sun/8.12.9/Submit) id i6SFsrgY014859;
	Thu, 29 Jul 2004 01:54:53 +1000 (EST)
X-NNTP-Posting-Date: Wed, 28 Jul 2004 09:59:43 MET DST
X-Spam-Level: 
X-Delivered-To: std-c++@ucar.edu
X-Spamscanner: mailbox1.ucsd.edu  (v1.4 May 20 2004 13:55:33, 0.1/5.0 2.63)
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Newsgroups: comp.std.c++
X-MailScanner: PASSED (v1.2.8 23622 i6S7xi1g039964 mailbox1.ucsd.edu)
Xref: g2news1.google.com comp.std.c++:1473

John Nagle wrote:
> Daniel Pfeffer wrote:
> 
>    We should have "std::pi" as a double, accurate to the last bit
> of a double, even if it has to be calculated offline and
> stored as a hex float.  This is worth doing, because it's
> a huge pain to do that and it only needs to be done once.
> 

Should std::pi be a constant? As my current programming platform is 
ix86-based I would prefer having a function instead. That's because 
there is a FPU instruction (namely FLDPI) that loads the value of pi in 
an FPU register. Calling FLDPI has a few advantages over a "regular" FLD 
load instruction, mostly the fact that there the value need not be read 
from memory and that the value is loaded at full internal precision 
(ix86 FPU registers internally have more precision than a double).

If std::pi is defined as a constant, it may be difficult for a compiler 
to generate an intrinsic call to FLDPI thus producing optimized code, 
while it may be easier if std::pi() is function (at least the machinery 
to replace calls to sin(), cos() etc. with intrinsics is already there).

Just my opinion,

Alberto

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



