Files
mql5-skills/skills/mql5/references/docs/08-math/0595-math-mathabs.md
T
2026-06-23 21:47:51 +08:00

44 lines
1.0 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# MathAbs
The function returns the absolute value (modulus) of the specified numeric value.
```
double  MathAbs(
   double  value      // numeric value
   );
```
Parameters
value
[in]  Numeric value.
Return Value
Value of double type more than or equal to zero.
Note
Instead the MathAbs() function you can use fabs().
Example:
```
//--- input parameters
input int      InpValue = -10;   // Enter any value here
 
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- get the absolute value of the number entered in the inputs
   uint abs_value=MathAbs(InpValue);
//--- print the values in the journal
   PrintFormat("The entered value %d received the value %u after using the MathAbs() function",InpValue,abs_value);
  }
```