Get the number of decimal places of any numbers (not just quotes) bypassing Digits() in MQL4 and MQL5 - page 5

 
A100:

You need one

so that

the result was: 4

Exactly four? Let's do it.

 
fxsaber:

Perhaps that is exactly the function you need. Answered the TC

He needs precisely such a function, because (as you correctly noted) not all numbers can be exactly represented as double, which means that solving the problem without specifying the accuracy is meaningless (because in the general case it leads to absurd results).

 
A100:

He needs exactly that, because (as you correctly noted) not all numbers can be accurately represented as a double, which means that solving the problem without specifying the accuracy is meaningless (because in general it leads to absurd results).

What are the options for specifying accuracy without changing the number of decimal places, or how can I eliminate the disadvantage I described in my version? For myself I found only (string)value

 
Alexandr Sokolov:

What are the options for specifying accuracy without changing the number of decimal places, or how can I eliminate the disadvantage I described in my version? For myself I found only (string)value

I guess you mean within what limits to look for the last non-zero.

 

I tried to do a calculation of the number of decimal places through MathMod() with a consecutive divisor 0.1, then 0.01 ... 0.000(15 zeros) 1, it did not work, the accuracy of the number keeps "floating" need to normalize each time, and if you use normalization, then it is easier to compare the number you want and normalized to what sign - if different, then found the last sign

HH: there is another option, did not have time to check - multiply a real number without an integer part of 10 ^ 16 and save it all in long, and then divide by 10 and check the remainder of the division, if = 0, then again divide

 
Igor Makanu:

ZS: there is another option, I have not had time to check - multiply a real number without an integer part by 10^16 and save it all in long, and then divide by 10 and check the remainder of the division, if = 0, then divide again

It won't work.

 
UsedoublePoint()
Decimal logarithm, sign discard...
 
Aliaksandr Hryshyn:
UsedoublePoint()
Decimal logarithm, sign discarded...

Also tested, no way.

That's it.

void OnStart()
{
 double p = 0.07;
 Print(p);
}/*******************************************************************/

It gives this result

2018.11.05 10:43:05.138 !00 (GBPJPY,H1) 0.07000000000000001
Guess three times what the logarithm is...
 
Alexey Viktorov:
Also tested, it won't work.
Why not? Round up to the whole.
 
Look at what the Point() function returns.
Reason: