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

 
multiplicator:
float is such a ***. these floats are nothing but trouble.

When will they make normal numbers for programming?

You can make a fractional number be stored in memory as an integer and a fractional part.

float is easier, it has less precision (digits after,) than double

are these normal numbers for programming? )))), apparently you want decimal, but alas, the developers have explicitly said (search admin Renat's posts) that there will be no new types

double into fraction, here didhttps://www.mql5.com/ru/forum/290279#comment_9396706

but I still need +, -, *, / to overload operators, so I'm not interested.

Число в дробь (convert double to fraction)
Число в дробь (convert double to fraction)
  • 2018.11.16
  • www.mql5.com
Ищу способ преобразовать вещественное число в дробь, нагуглил исходник https://stackoverflow...
 
Igor Makanu:

float is easier, it has less precision (digits after,) than double

are these normal numbers for programming? )))), apparently you want decimal, but alas, the developers explicitly said (search admin Renat's posts) that there will be no new types

double to fraction, here didhttps://www.mql5.com/ru/forum/290279#comment_9396706

but there still need operators +, -, *, / to overload, so far not interesting abandoned

Yes, DECIMAL.



Or develop your own type. so that the number is stored in memory as its integer part and its fractional part.
like two integers.



2 147 483 647.2 147 483 647



and it would take up as much memory as two integers. 8 bytes.

 
multiplicator:

Yes, DECIMAL.



Or develop your own type to store the number as its integer part and its fractional part.
like two integers.



2 147 483 647.2 147 483 647



And it would take up as much memory as two integers. 8 bytes.

there is already a standard double-double arithmetic

https://en.wikipedia.org/wiki/Quadruple-precision_floating-point_format

Quadruple-precision floating-point format - Wikipedia
Quadruple-precision floating-point format - Wikipedia
  • en.wikipedia.org
This 128-bit quadruple precision is designed not only for applications requiring results in higher than double precision,[1] but also, as a primary function, to allow the computation of double precision results more reliably and accurately by minimising overflow and round-off errors in intermediate calculations and scratch variables. William...
 
Taras Slobodyanik:

there is already a standard double-double arithmetic

https://en.wikipedia.org/wiki/Quadruple-precision_floating-point_format

On the contrary, I want to get away from double-double, and you suggest double-double.

Dables store a number in memory in an inaccurate form.
I gave you a video.
 
multiplicator:
I, on the contrary, want to get away from dubles, and you're offering me a duble-duble.

dubles store the number in memory in an inaccurate form.
I gave you a video.

Well, if speed of calculation and compatibility are not important, then yes you can count as you like.
But as soon as these numbers need to be used somewhere - you will have to convert everything back to dable, to an inaccurate number.

 
Taras Slobodyanik:

Well, if speed and compatibility are not important, then yes, you can count as you like.
But as soon as these numbers need to be used somewhere, you have to convert everything back to a double, inaccurate number.

Well, in decimal, it's OK. They are somehow divided by each other and stored in exact form.

 
multiplicator:

Well, in decimal it's fine. somehow they are divided by each other and stored in exact form.

well, not in decimal, but in fractions

and in decimal you have to accept the same inaccuracy-abbreviations, because it is impossible (unnecessary) to write infinite exact numbers

 
multiplicator:

Well, in decimal it's OK. somehow they're divided by each other and saved in exact form.

I wonder how you will count logarithms, degree conversions with non-integer numbers, use trigonometry, .... use third party libraries, indicators... They're all in error!
 
Aliaksandr Hryshyn:
I wonder how you'll count logarithms, powers with non-integer numbers, use trigonometry, .... use third-party libraries, indicators... They're all error-prone!
You're used to working with decimal numbers rather than binary numbers.
and you're used to where the margin of error might be.
 

https://www.mql5.com/ru/forum/287618/page3#comment_9240442

This is probably the best solution, but it will be 40% faster (for some reason mql slows down in loops)

int d2(double x){
  if(x==NormalizeDouble(x,6))
   {
    if(x==NormalizeDouble(x,5))
     {    
      if(x==NormalizeDouble(x,4))
       {
        if(x==NormalizeDouble(x,3))
         {
          if(x==NormalizeDouble(x,2))
           {
            if(x==NormalizeDouble(x,1))
             {
              if(x==NormalizeDouble(x,0))
               {
                return 0;
               }
              return 1;
             }
            return 2;
           }
          return 3;
         }
        return 4;
       }
      return 5;
     }
    return 6;
   }
  return 7;
}
Получаем количество десятичных знаков после запятой любых чисел (не только котировок) в обход Digits() на MQL4 и MQL5
Получаем количество десятичных знаков после запятой любых чисел (не только котировок) в обход Digits() на MQL4 и MQL5
  • 2018.11.03
  • www.mql5.com
Думаю не у одного меня была редкая ситуация когда нужно было получить количество десятичных знаков после запятой, а функция Digits() работает тольк...
Reason: