Opened 16 years ago

Closed 16 years ago

#725 closed Bugs (Invalid)

floating point comparison algorithm

Reported by: nobody Owned by: Gennadiy Rozental
Milestone: Component: test
Version: None Severity:
Keywords: Cc:

Description

The floating point comparison algorithm does not seem 
to work if one of the floating points is zero and the 
other one is close to zero. Here's the code sample 
I've used:

close_at_tolerance<double> checker(0.01);

const double a = 0.0;
const double b = 0.0000001;

bool res = checker(a, b);
if (!res)
{
  std::cerr << "ERROR" << std::endl;
}

I think the following check must be added in the 
close_at_tolerance<FPT>::operator() function:
bool operator()( FPT left, FPT right ) const
{
   if (left == 0.0 || right == 0.0)
   {
      return (p_fraction_tolerance.get() >  
              tt_detail::fpt_abs(left-right));
   }

   // ...
}

My email address is "tom.vanroey@vito.be".

Change History (1)

comment:1 by Gennadiy Rozental, 16 years ago

Status: assignedclosed
Logged In: YES 
user_id=331868

Not a bug
Note: See TracTickets for help on using tickets.