Hi I want to count whole numbers. for example: 1.23456 is counted as 1 because there is only 1 whole number, for 123.456 it must be 3 and so on. I didn't find any predefined variable for this. does anyone knows way how to do that? Thanks!
- [Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2.
- finding latest swing high and swing low
- Counting Up Arrows
#define IntegerDigitsCount(x) ((int)MathLog10(MathAbs(x)) + 1) //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OnStart() { Print(IntegerDigitsCount(1.23456)); Print(IntegerDigitsCount(123.456)); } //+------------------------------------------------------------------+ // output: // 1 // 3
Note that the function MathLog10() for numbers is somewhat like StringLen() for strings.
amrali:
Note that the function MathLog10() for numbers is somewhat like StringLen() for strings.
Thanks it works perfectly
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register