Subject: RE: [cxxpanel] does this solve the problem?
From: "Paul A Bristow" <[email-masked]>
To: <[email-masked]>
Date: Fri, 20 May 2005 11:45:28 -0000

This topic received exhaustive suggestions, some very close to this,
during the Boost review of my math constants library.

In the end they could not reach agreement, mainly because
not everyone agreed that it catered for User Defined Types
(NTL quad, doubledouble, RWdecimal...)
well enough (though there are conflicting views on which of the
many possibilities are best - for example using namespaces
allows one to deal with the case (<95%) on only ever wanting
doubles neatly so the user uses one using statement to
say he only ever wants pi<double>.  

I though that the scheme proposed by Michael Kenniston was OK,
(see Boost sandbox files at URL below) but others shot it down.

However I recently reignited the debate by posting some updated
versions (with even more accurate constant values)

to the boost sandbox

http://tinyurl.com/7p6es

See attached descriptive email which went with it.

Daniel Frey has another scheme which works OK on EDG and GCC
but not MSVC and I doubt is legal C++,
and another which relies on typeof,
a kludge version of which is the subject of an ongoing Boost review.

With C++0X and a proper typeof, I would probably support this version.

This doesn't seem rocket science to sort out somehow,
but C++ seems to find it hard.  

An additional recent complication is that the Standard stream input
does not seem to require that when you read into a stream object like a
streamstring
you get exactly when you would get from the compiler reading in a
declaration like

const double pi = 3.141592653589793238462643383279502884197; // pi

stringstream s_pi ("3.141592653589793238462643383279502884197");

s_pi >> stream_pi; // pi not necessarily == stream_pi !!!
(for MSVC 8.0 is 1 bit wrong in 1/3 of cases - according to MS a feature not
a bug!)

See details attached.

:-((

Paul

Paul A Bristow
Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB
+44 1539 561830  +44 7714 330204
mailto: [email-masked]

| -----Original Message-----
| From: [email-masked] 
| [mailto:[email-masked]] On Behalf Of Francis Glassborow
| Sent: 20 May 2005 11:36
| To: [email-masked]; Walter Brown
| Subject: [cxxpanel] does this solve the problem?
| 
| 
| For those not familiar with the problem, Walter Brown wants a 
| mechanism 
| by which, for example, a value of pi in a user selected type can be 
| available.
| 
| In essence he wants to be able to write:
| 
| pi<double>
| pi<long double>
| pi<float>
| 
| We know that this can be done with a template function but his users 
| really, really hate appending empty parentheses.
| 
| Does this suggestiion from Gaby (an I think indepedently from someone 
| else) do it:
| 
| 
| 
| struct PiType
| {
|      template <typename T>
|      operator T() const { return 3.1415926536; }
| } pi;
| 
| The object "pi" above can be used in generic code (like the
| area_of_circle function). Specializations for different types or even
| distinguishing reads from writes are possible as well.
| 
| -- 
| Francis Glassborow
| 
| 
| 
| To unsubscribe from this group, send an email to:
| [email-masked]
|  
| Yahoo! Groups Links
| 
| 
| 
|  
| 
| 
| 

To unsubscribe from this group, send an email to:
[email-masked]
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://uk.groups.yahoo.com/group/cxxpanel/

<*> To unsubscribe from this group, send an email to:
    [email-masked]

<*> Your use of Yahoo! Groups is subject to:
    http://uk.docs.yahoo.com/info/terms.html

Subject: [boost] Math constants - updated.
From: "Paul A Bristow" <[email-masked]>
To: "Boost" <[email-masked]>
Date: Fri, 6 May 2005 18:16:43 -0000

I have recently posted to the Boost Sandbox vault an update of my collection
of mathematical constants,
previously reviewed as a Boost library and ultimately not accepted because
of
lack of agreement on how to present the constants, especially for User
Defined Types,
and an outbreak of macrophobia.

However the values are still valid and some may find them a useful and
convenient source,
with even more reassuringly sufficient decimal places to give you a warm
feeling ;-)

The values are take from Internet sources and then computed with NTL a
arbitrary (very high) precision library
and presented as 40 decimal digit strings, suitable for all hardware as yet
envisioned.
I have tried to check as many as possible against two source to try to avoid
mistakes,
but please tell me of any that you find.

The same values are actually presented in header files as macros, floats,
doubles, and long doubles,
(and also as the functions allowing pi to call a function pi() proposed by
Michael Kenniston,
even though I am not entirely convinced of their usefulness).

So including double_constants.hpp will give lots of values, for example:

static const double cubeRootTwo = 1.25992104989487316476721060727822835057;
// 2^1/3

If you prefer a macro, the define_constants.h will give you values like

#define M_EPOWPI 23.14069263277926900572908636794854738027L  /* e^pi */

You can of course also cut and paste invididual lines, if you just want pi.

No choice of names will suit everyone - so I have indulged myself.

You can change them of course.

http://tinyurl.com/7p6es

for two zips of headers and documentation as html.

Enjoy?

Paul

PS Some of these values are to be used in the math functions for stats
library
that I am in danger of getting around to Real Soon Now.

Paul A Bristow
Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB
+44 1539 561830  +44 7714 330204
mailto: [email-masked]

_______________________________________________
Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost