Boost logo

Boost :

Subject: Re: [boost] [endian] Testing floating point interoperability
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2015-03-18 12:29:12


> -----Original Message-----
> From: Boost [mailto:boost-bounces_at_[hidden]] On Behalf Of Steven Watanabe
> Sent: 18 March 2015 15:20
> To: boost_at_[hidden]
> Subject: Re: [boost] [endian] Testing floating point interoperability
>
> AMDG
>
> On 03/18/2015 07:24 AM, Beman Dawes wrote:
> > On Fri, Jan 30, 2015 at 5:25 AM, Paul A. Bristow
> > <pbristow_at_[hidden]> wrote:
> >>
> >> You can't test all possible values (except for 32-bit float - 64-bit
> >> double takes about 50 years at current processor speeds ;-) but you
> >> can chose values (floating-point bit patterns) at random for a test
> >> lasting some minutes or even hours.
> >
> > Could you provide the random number generation and otherwise help with
> > this? I've only ever used integer RNGs.
> >
>
> Since you want to test random bit patterns, the easiest way is to generate a 64-bit integer and
memcpy it to a double.

I'm not sure if it will prove realistic to test all the possible NaN patterns provided by IEEE
floating-point layout?

I would expect only those 'funny numbers' in std::numeric_limits to work

  numeric_limits<>::infinity()
  -numeric_limits<>::infinity()
  numeric_limits<>::quiet_NaN()

  perhaps (despite its meaninglessness) even

-numeric_limits<>::quiet_NaN()

There was some discussion about removing signaling_NaN

std::numeric_limits<float>::signaling_NaN() representation is
0x7fc00001 for Microsoft/Dinkumware, but is 0x7fa00000 for gcc and clang:-(

I would simply accept and document that signaling_NaN won't work (unless it does ;-)?

But if all of the tests prove to work, then fine.

If not, then in our round-trip testing John and I just tested for 'funny' with

#include <boost\math\special_functions\fpclassify.hpp>

template <class T>
bool isfinite(T z); // Neither infinity nor NaN.

template <class T>
bool isinf(T t); // Infinity (+ or -).

template <class T>
bool isnan(T t); // NaN.

and choose another value if !isfinite.

HTH

Paul

---
Paul A. Bristow
Prizet Farmhouse
Kendal UK LA8 8AB
+44 (0) 1539 561830

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