-1

I have double vector array ( vector< double > ) and its max value ( 1 ) and min value ( 0 ).

When I did below sub operation, log gives (1.#INF00000000000000000) for max value's index that ( 1 - 1.000000000000001 ) ( double precison ).

How can I prevent this precision error?

log( 1 - array[ i ] );

1 Answers1

0

Do you mean this?

if(array[i] >= 1)
  return 0;
else if(array[i] <= 0)
  return std::numeric_limits<double>::infinity();
else
  return log(1 - array[i]);
ChronoTrigger
  • 8,459
  • 1
  • 36
  • 57