Changeset 840 for branches/0.3.1


Ignore:
Timestamp:
Apr 25, 2007, 9:55:37 AM (15 years ago)
Author:
Jari Häkkinen
Message:

Addresses #222. Comparing doubles with == is poor programming style.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/0.3.1/test/averager_test.cc

    r831 r840  
    3030#include "yat/utility/vector.h"
    3131
     32#include <cmath>
    3233#include <fstream>
    3334#include <limits>
     
    229230bool equal(const Averager& a, const Averager& b)
    230231{
    231 //  std::cout << (a.n()==b.n()) << std::endl;
     232//  std::cout << (a.n()==b.n()) << std::endl;
    232233//  std::cout << (a.mean()==b.mean()) << std::endl;
    233 //  std::cout << (a.variance()==b.variance()) << std::endl;
    234   return (a.n()==b.n() && a.mean()==b.mean() && a.variance()==b.variance());
     234//  std::cout << (fabs(a.variance()-b.variance()<1e-15)) << std::endl;
     235  return (a.n()==b.n() && a.mean()==b.mean() &&
     236          fabs(a.variance()-b.variance()<1e-15));
    235237}
    236238
Note: See TracChangeset for help on using the changeset viewer.