Boost logo

Boost :

From: Paul A Bristow (pbristow_at_[hidden])
Date: 2006-08-02 09:29:41


 

| -----Original Message-----
| From: boost-bounces_at_[hidden]
| [mailto:boost-bounces_at_[hidden]] On Behalf Of Johan Råde
| Sent: 02 August 2006 09:44
| To: boost_at_[hidden]
| Subject: Re: [boost] [serialization] facets for non-finite numbers
|
|
|
| > Johan Råde wrote:
| > | I note that:
| > |
| > | The output from the extended_num_put facet is consistent
| > | with the C99
| > | standard, except that I do not put signs on NaNs. I
| will not change
| > | that, since there is no reasonable way for a C++ program to
| > | detect that sign.
|
| Paul A. Bristow wrote:
|
| > Surely C99 signbit tests the sign bit? (And is best used
| for testing the
| > sign of infinity?)
| >
| > | (And the sign has no meaning anyway, unlike infinity
| > | where a sign sometimes, but not always, does have meaning.)
| >
| > Mathematically, you are absolutely correct, but I have argued,
| > and continue to argue strongly, that there really IS a sign bit,
| > and that it is unnecessary, indeed wasteful,
| > to prevent users from making some entirely private use
| > of this potentially precious sign bit,
| > when it costs almost nothing to simply output a '-' if the
| NaN has the sign
| > bit set.
|
| You are right, but our goals are different. You are working on a
| proposal to the C++ standardization committee. I writing code that
| should work with existing C++ compilers and std lib
| implementations. So I can not assume that the C99 signbit macro is
present.

OK, so why not write - or get someone else to write ;-)
a C++ is_negative function,
and use the signbit macro if available,
or make up your own bit test if not?

There are a few variations with type, endianness and compiler, of course,
but not TOO many?

| What do you thing of Robert Ramey's idea of making it possible to
| configure a stream to report an error when a non-finite number is
| inserted or extracted? This could be done with a new stream flag and
| corresponding manipulators.

Some check would seem extremely wise, or archives may later prove unreadable
:-((

But I am uncertain how best to do it.

Paul

---
Paul A Bristow
Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB
+44 1539561830 & SMS, Mobile +44 7714 330204 & SMS
pbristow_at_[hidden]
 

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk