Rounding numbers in MT4 via NormalizeDouble

 

Hello. Can you tell me what the problem is.

Why does the NormalizeDouble(0.055,2) function round the number "0.055" to "0.06"?

It's not a fraction rounding function.

 

https://docs.mql4.com/ru/convert/normalizedouble

Округление числа с плавающей точкой до указанной точности.

NormalizeDouble - Документация на MQL4
  • docs.mql4.com
NormalizeDouble - Документация на MQL4
 

To continue the theme. There is a script

#property strict

void OnStart()
  {
   double v1 = NormalizeDouble(0.055,2);
   double v2 = NormalizeDouble(0.0549,2);

   Print("v1 = ",DoubleToString(v1),", v2 = ",DoubleToString(v2));
  }

result: v1 = 0.06000000, v2 = 0.05000000, while it should be 0.06000000 in both cases.

 
Maxim Khrolenko:

To continue the theme. There is a script

result: v1 = 0.06000000, v2 = 0.05000000, while it should be 0.06000000 in both cases.

Rounding - Wikipedia

 
Roman Starinskij:

Hello. Can you tell me what the problem is.

Why does the NormalizeDouble(0.055,2) function round the number "0.055" to "0.06"?

It's not a fraction rounding function.

What do you think the result should be?
 
Maxim Khrolenko:

To continue the theme. There is a script

result: v1 = 0.06000000, v2 = 0.05000000, while it should be 0.06000000 in both cases.

Why the hell not?
 
Maxim Khrolenko:

To continue the theme. There's a script

Result: v1 = 0.06000000, v2 = 0.05000000, while it should be 0.06000000 in both cases.

well, vshchupeeeeeee....

Should be v1=v2=0.06.

I've never even checked it... Is it really that bad?

Do you have MT5 or MT4?

 
new-rena:

well,wow,wow,wow,wow,wow,wow,wow,wow,wow,wow,wow.

should be v1=v2=0.06.

I've never even checked... Is it really that messed up?

Why on earth would it do that?
 
Dmitry Fedoseev:
Why would you do that?

I got a D in school, but I remembered rounding correctly...

If the rightmost number is greater than or equal to 5, then the next number to the left is +1. And so on, shift from right to left.

 
new-rena:
I got straight F's in school, but I remember this...

Interesting, what kind of school is this... Tell me what you're thinking. Because I don't have any idea how it could be so clichéd.

 
Maxim Khrolenko:

To continue the theme. There is a script

result: v1 = 0.06000000, v2 = 0.05000000, while it should be 0.06000000 in both cases.

And you're normalizing 3 characters after the decimal point