Boost logo

Boost Testing :

From: Robert Ramey (ramey_at_[hidden])
Date: 2005-11-17 13:54:11


The problem is given something like +/inf how do I create a float with that value?

Can I use something like this?

double x;
x = std::numeric_limits<T>::quiet_NaN();

assert(x == std::numeric_limits<T>::quiet_NaN());

Robert Ramey

"Caleb Epstein" <caleb.epstein_at_[hidden]> wrote in message news:989aceac0511171024g42ca640dvff8257333577e6e2_at_mail.gmail.com...
  On 11/17/05, Kevin Wheatley <hxpro_at_[hidden]> wrote:

    don't know of a great solution but under IEEE class floats can't you
    compute the numbers...

    NaN = 0/0
    +inf = +1/0
    -inf = -1/0
    +0 = 0/+1
    -0 = 0/-1
    etc.

  The +/-0 formulas work, but not the NaN and +/-Inf ones (divide by zero generates a floating point exception). Thankfully, can't we use numeric_limits for some of these?

  std::numeric_limits<T>::infinity()

  std::numeric_limits<T>::quiet_NaN()
  std::numeric_limits<T>::signaling_NaN()

  std::numeric_limits<T>::denorm_min()

  --
  Caleb Epstein
  caleb dot epstein at gmail dot com

------------------------------------------------------------------------------

  _______________________________________________
  Boost-Testing mailing list
  Boost-Testing_at_[hidden]
  http://lists.boost.org/mailman/listinfo.cgi/boost-testing



Boost-testing list run by mbergal at meta-comm.com