Boost logo

Boost Users :

From: tirath (research-lists_at_[hidden])
Date: 2006-10-18 13:03:24


Hi all,

Background...
I'm using the interval arithmetic library to evaluate the accuracy of
different algorithms for my application (i.e. I'm using the library
"offline"; once a winner is chosen, the interval arithmetic will be
removed).

One possibility that I am pursuing is using mixed precision
arithmetic; i.e. do some parts in double precision, some parts in
single precision - this is to explore the possibility of eventually
utilising non-conventional processing hardware such as GPUs, which
tend to have only single precision arithmetic hardware.

The query...
Before I started using the library, I had this assumption: let A be a
float with an exact representation (i.e. width=0). If we cast A to a
double, the resulting double will have a non-zero width -
specifically the width will be equal to the extra precision afforded
to doubles vs floats.

Unless I've messed something up, I find that the library does not
actually behave this way, and to be frank, I think it ought to! :-)
Here's the simple testcase:

typedef interval<float> I1;
typedef interval<double> I2;
I1 y = 1.0;
I2 yy = (I1)y;
cout << yy.upper() - yy.lower();

I expected yy.upper()-yy.lower() to be non-zero, but it was zero. I
had a look at the policies but couldn't spot anything obviously
relevant to this situation. Any thoughts on this behaviour per se, or
any ideas on a neat and elegant way to implement my desired behaviour?

FWIW, my system is PowerPC G4 with powerpc-apple-darwin8-g++-4.0.0
(GCC) 4.0.0 20041026 (Apple Computer, Inc. build 4061).

-tirath


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net