**Icham Aidibe:**Why ? returns : I've asked 2 digits, two digits are 0.09 ; not 0.09 rounded to 0.1

That is correct. Rounding to two digits would result in 0.10, so 0.1 is correct!

You asked for "rounding" and not "truncation" or "floor". *NormalizeDouble* rounds the value — *"Rounding floating point number to a specified accuracy."*

- www.mql5.com

**Icham Aidibe #:**No fernando. I asked for 2 digits. Anyway. Do you know any workaround to this ? I know you're plenty of tricks

There is no workaround because it is mathematically correct. It's not a bug. If you don't want to "round", then use "floor" instead.

EDIT:

floor( x * 100.0 ) / 100.0; // Two digit truncation

I don't want to round, nor to floor. I want to normalize.

I want 2 digits on that double. it is not negligible, do you know the value of the first 2 digits of a double in btc ? It's $2000.

**Icham Aidibe #:**I don't want to round, nor to floor. I want to normalize.

I want 2 digits on that double. it is not negligible, do you know the value of the first 2 digits of a double in btc ? It's $2000.

normalize is rounding ... read the documentation ... *NormalizeDouble* rounds the value — *"Rounding floating point number to a specified accuracy."*

The requirement you have explained is the same as floor/truncation.

If the original value is 0.09906800, then for two digits ...

- Rounding gives 0.10
- Normalising (which is rounding) gives 0.10
- Floor (which is truncation) gives 0.09
- Ceiling gives 0.10

The floor doesn't work.

void OnStart() { double x = 9906.8 / 100000; printf("x = %s",DoubleToString(x)); printf("ND(x) = %g",MathFloor(x)); }

2022.10.05 13:55:20.546 NB (EURUSD,H1) x = 0.09906800 2022.10.05 13:55:20.546 NB (EURUSD,H1) MF(x) = 0(at least not as you said)

I gone with the strings but the floor ok !

void OnStart() { double x = 9906.8 / 100000; printf("x = %s",DoubleToString(x)); printf("ND(x) = %g",StringToDouble(StringSubstr(DoubleToString(x,3),0,StringLen(DoubleToString(x,3))-1))); printf("Floor : %g",floor(x*100.0 )/100.0); }

2022.10.05 14:07:23.384 Tst (EURUSD,H1) x = 0.09906800 2022.10.05 14:07:23.384 Tst (EURUSD,H1) ND(x) = 0.09 2022.10.05 14:07:23.384 Tst (EURUSD,H1) Floor : 0.09

thank you fernando ! have a nice day ! 👍

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets

You agree to website policy and terms of use

Why ?

returns :

I've asked 2 digits, two digits are 0.09 ; not 0.09 rounded to 0.1