Speed of execution of the functions ceil(),round(),floor() - page 8

 
Nikolai Semko:

Option for positive and negative numbers:

This seems to be a full-fledged replacement for ceil(),round(),floor(), which gives 3-4 times speed advantage.

Looks more or less decent. I ran your _round(), remember showing the compare_prices() function. So, there's a script that searches for price patterns, obviously compare_prices() is called there very actively. Results:

compare_prices with std round and with point difference checking = 13 sec
compare_prices with std round and with point difference checking turned off = 19 sec
compare_prices with your _round and with point difference checking turned off = 15 sec
compare_prices with your _round and with point difference checking turned on = 13 sec


The conclusion is that the lion's share of calls in real-world tasks ends at checking in Point. Time is the same (when checking for differences at Point is on), but working range has fallen from 1.7*10^308 to about 2*10^9 (or ^19 if using long) (although a big round is needed as a fifth wheel in a cart). I don't know, maybe you use these functions exotically somehow ...

SZU:

Alert( _ceil(-1+DBL_EPSILON) );   // 2.220446049250313e-16

wrap x in brackets.

 
If the CPU time you save is multiplied by a billion, even then it would be less than the time you spent discussing IMHO
 
Alexey Navoykov:

It looks like Nikolai was right about the nerds )).

Personally, I didn't see any personal attacks there. And you do have a lot of letters in your posts, but everything is off-topic, it feels like you're arguing just for the sake of arguing.


 
LRA:
If the CPU time you save is multiplied by a billion, even then it would be less than the time you spent on the discussion IMHO

Yes, I agree, wasted time is a pity - fact.

 
Nikolai Semko:

Yes, I agree, it's a waste of time - that's a fact.

Then why did you write here in the first place? I thought it was for discussion, discussion. Well, don't be so unreasonable. But do not relax, you have a whole unploughed field in front of you https://www.mql5.com/ru/docs/math. Good luck))

Документация по MQL5: Математические функции
Документация по MQL5: Математические функции
  • www.mql5.com
Математические функции - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
pavlick_:

It looks more or less decent. I ran your _round(), remember showing the compare_prices() function. So, there's a script that searches for price models, obviously compare_prices() is called there very actively. Results:

So the conclusion is that the lion's share of calls in real tasks ends at checking in Point. Time is the same (when checking for differences at Point is on), while working range has fallen from 1.7*10^308 to about 2*10^9 (or ^19 if using long) (although a big round is needed as a fifth wheel of a cart). I don't know, maybe you use these functions exotically somehow ...

ZS:

Wrap x in brackets.


I could not understand - in what cases is it necessary to use this function:?

// 0 - first is greater than second
// 1 - equal
// 2 - second is greater than first
uchar compare_prices(double first, double second)
{
   if(first - second >= _Point)
      return 0;
   if(second - first >= _Point)
      return 2;

   first = round(first/_Point);
   second = round(second/_Point);
   
   if(first > second)
      return 0;
   if(first < second)
      return 2;
   return 1;
}

why notjust use if (first>second), or if you need a result (0,1 or 2) :

#define _compare_prices(f,s) (f>s)?0:(f<s)?2:1;

Because you don't need rounding functions here.

Or is it just for a test?

 
Nikolai Semko:

No, this is a real function. Just for the sake of interest, I've tweaked it into my workings. Nikolai, well, I understand that there's no need for discussion. I'll leave it at that.

 
pavlick_:

No, this is a real function. Just for the sake of interest, I've tweaked it into my workings. Nikolai, well, I understand that there's no need for discussion. I'll leave it at that.

pavlick_:

Then why did you write here at all? I thought it was for discussion, I'm discussing. Well, don't be so unreasonable. But you do not relax, in front of you whole unploughed field https://www.mql5.com/ru/docs/math. Good luck.)

:) What I meant was that it's a pity for the time wasted on "sorting things out", unfortunately in this thread it has happened. No time is wasted on constructive discussion.
Reason: