Libraries: Math Utils (MT4) - page 3

 
Fernando Carreiro #:
I don't think so! It's probably "future proofing" for the day it becomes a "reality". 😅
Psychological coding
 
Alain Verleyen #:
Psychological coding
😀yes psychological impact.
It is actually inlined by the compiler.
 
@amrali #: 😀yes psychological impact. It is actually inlined by the compiler.

It is? When was that implemented? Last I read, it was just for compatibility's sake and nothing else.

 
Fernando Carreiro #:

It is? When was that implemented? Last I read, it was just for compatibility's sake and nothing else.

It's what amrali want to say I think, it's automatically inlined by the compiler, whatever "inline" keyword is used or not.
 
Alain Verleyen #: It's what amrali want to say I think, it's automatically inlined by the compiler, whatever "inline" keyword is used or not.

Yes, that part I knew about, that optimised compilation implements inlining, which is under compiler control and not user control.

As for the of "inline", "__inline" and "__forceinline", it is only for cosmetic compatibility with C/C++ to make porting code easier, as far as i know (since build 1910 or 1930, I think).

 
Fernando Carreiro #:

Yes, that part I knew about, that optimised compilation implements inlining, which is under compiler control and not user control.

As for the of "inline", "__inline" and "__forceinline", it is only for cosmetic compatibility with C/C++ to make porting code easier, as far as i know (since build 1910 or 1930, I think).

Yes exactly like Alain said. It is inlined when optimizations are on. I used it to hint that mql compiler has some updates that are ongoing under the hood. inline keyword itself has no advantage till now.
 

Update 24 April 2023

Added new function:

//+------------------------------------------------------------------+
//| Wrap a value between min (inclusive) and max (exclusive).        |
//+------------------------------------------------------------------+
template<typename T>
T Wrap(const T value, const T min, const T max);

Renamed the rounding functions to Ceil(), Floor(), Round() and Trunc() to avoid name conflicts with <Math\Stat\Math.mqh>.

Fixed the GetDigits() function to avoid an infinite loop in rare situations.