Libraries: Price_Compare

 

Price_Compare:

This small cross-platform library allows to compare the 'double' values of the "price" conveniently and quickly.

Author: fxsaber

 
Automated-Trading:

Price_Compare:

Author: fxsaber

Interesting.

#define EPSILON (1.0e-7 + 1.0e-13)
Why is your EPSILON defined as this value ?


 
Alain Verleyen:

Why is your EPSILON defined as this value ?

I do not remember...

Форум по трейдингу, автоматическим торговым системам и тестированию торговых стратегий

Альтернативные реализации стандартных функций/подходов

fxsaber, 2016.09.02 10:58

double MyNormalizeDouble( const double Value, const uint digits )
{
  static const double Points[] = {1.0e-0, 1.0e-1, 1.0e-2, 1.0e-3, 1.0e-4, 1.0e-5, 1.0e-6, 1.0e-7, 1.0e-8};
  const double point = digits > 8 ? 1.0e-8 : Points[digits];
  const long Integer = (long)Value; // чтобы не создавать крайне медленный относительный epsilon

  return((long)((Value > 0) ? (Value - Integer) / point + HALF_PLUS : (Value - Integer) / point - HALF_PLUS) * point + Integer);
}