Double vs FLOAT - unclear MathFloor error - page 4

 
Andrey Dik:
float is the castration of numbers and offers no advantage. Better deal with all the losses in conversions and use the highest possible precision - double.
Thank you. I will try to figure out where I made a mistake after all. For now float is still working as well. I'm not in the habit of giving up what I've started. But this error threw me off balance.
 
Vladislav Andruschenko:
Thank you. I'll try to figure out where my error was. In the meantime, the float is working. I'm not used to quitting. But this error threw me for a loop.
It is up to you, but note that ALL standard math functions work with numbers double and produce results double. Applying these functions to float numbers produces internal conversion to double, so you will lose precision and validity of results anyway.

Personally, I never use in calculations and comparisons of numbers the method comparing difference with some minimal accepted value, I always work with maximum possible accuracy up to 16th sign, and only in last operation I do normalization. If you handle double correctly there is no problem, which I advise you to do, otherwise you will encounter problems in distortion of the results associated with a loss of accuracy in one of the steps of the calculations / conversions.
 
Andrey Dik:
It's up to you, but note that ALL standard math functions work with double numbers and give double results. Applying these functions to float numbers is still an internal conversion to double, so in any case, you will lose accuracy and validity in the results obtained.

Personally, I never use in calculations and comparisons of numbers the method comparing difference with some minimal accepted value, I always work with maximum possible accuracy up to 16th sign, and only in last operation I do normalization. If you work with double correctly no problems, which I advise you to do, otherwise you will encounter problems with distortion of the results associated with a loss of accuracy in one of the steps of the calculations / conversions.
Thank you for your comprehensive answer.
 

the rating price in 2017 is unabashedly correct

it's not the moths, it's the manure...

 
Mikhail Dovbakh:

the rating price in 2017 is unabashedly correct

Tell us.
 

that's how it should be

double Averab=(Ask+Bid)/2/_Point;
double AUTOPRICE=MathFloor( NormalizeDouble(Averab,2) )*_Point;
 
Taras Slobodyanik:

it should be like this.

double Averab=MathAbs(Ask-Bid)/2/_Point;
double AUTOPRICE=MathFloor( NormalizeDouble(Averab,2) )*_Point;


You've changed your code several times.

I did the same thing. I experimented, I understood what double and int are, but when I explicitly calculated they were not what I needed.

The first line is what you suggested.

MathFloor( NormalizeDouble((Ask+Bid)/Point,_Digits) )*Point
2017.02.26 18:24:59.133 2017.01.02 00:03:00  Exp - DOUBLE TEST MATHFLOOR EURUSD,M30: MathFloor=2.10287
2017.02.26 18:24:59.133 2017.01.02 00:03:00  Exp - DOUBLE TEST MATHFLOOR EURUSD,M30: DOUBLE    askP2=105146 bidP2=105141 Averab2=105143.5000000000 AUTOPRICE=1.0514300000
2017.02.26 18:24:59.133 2017.01.02 00:03:00  Exp - DOUBLE TEST MATHFLOOR EURUSD,M30: FLOAT    askP=105146 bidP=105141 Averab=105143.5000000000 AUTOPRICE=1.0514299870
 

so that's right105143.5000000000 rounded down to 43...

(46-41)/2 = 2.5, rounded down = 2

 
Taras Slobodyanik:

so that's right105143.5000000000 rounded down to 43...

(46-41)/2 = 2.5, rounded down = 2


that's right,

but with different spreads (2,3,4,5,6,7) the downward rounding is different and sometimes not quite accurate.

 
Checked from 0 to 8 everything's OK...
Reason: