# How to trim to i.e. 2 decimal places in the Data window? - page 2

5763

dzfx5:

LOL... I unswer exactly to topic question -> how to trim number till 2 digits after dot!
(If MathRound or NormalizeDouble or any etc. function dont work properly on "some numbers")

I mean -> there is no difference WHERE you place your number.. you must "prepare" it before placing anywhere.. ;)

Wrong! To change the number of digits in the Data windows for Inidcator Output, you have to specifically tell the Indicator the number of digits to display! You can't just use rounding or normalising. The correct solution is something like this (as mentioned in post #3):

```// Set Number of Significant Digits (Precision)
IndicatorSetInteger( INDICATOR_DIGITS, _Digits );```
15

Fernando Carreiro:

Wrong! To change the number of digits in the Data windows for Inidcator Output, you have to specifically tell the Indicator the number of digits to display! You can't just use rounding or normalising. The correct solution is something like this (as mentioned in post #3):

If your number is not correcly rounded, than you will output 00000000000001 digits after dot.

This question actually is about ROUNDING numbers, cos post author knows this ->

`IndicatorSetInteger( INDICATOR_DIGITS, _Digits );`

(he can get it from MQL functions dictionary as we all do.. :D)
, but this post author gets wrong output anyway ?!

All I want say -> round number correctly before output and then use "window or any" specific commands for output limiting -> IDICATOR_DIGITS, etc.

And I want repeat -> you must "prepare" it before placing anywhere.. ;)

5763

dzfx5:

If your number is not correcly rounded, than you will output 00000000000001 digits after dot.

This question actually is about ROUNDING numbers, cos post author knows this ->

(he can get it from MQL functions dictionary :D)
, but this post author gets wrong output anyways.

All I want say -> round number correctly before output and then use "window or any" specific commands for output limiting -> IDICATOR_DIGITS, etc.

And I want repeat -> you must "prepare" it before placing anywhere.. ;)

NO! The OP clearly stated that he only wanted 2 digits to be displayed after the decimal point, in the Data window, and even gave a screenshot where 6 digits were displayed and his value was ALREADY rounded to 2 digits.

Your answer is not valid for the question placed by the OP, and even a moderator called your attention to this. So, please don't insist!

15

Fernando Carreiro:

NO! The OP clearly stated that he only wanted 2 digits to be displayed after the decimal point, in the Data window, and even gave a screenshot where 6 digits were display and he value was ALREADY rounded to 2 digits.

Your answer is not valid for the question placed by the OP, and even a moderator called your attention to this. So, please don't insist!

LOL.. ok, i give up :D :D :D
(if you dont hear me)

Comment to "ALREADY rounded to 2 digits" -> this is MAIN problem(!), cos it wasn't actually rounded..
cos simetimes using defided funtions (NormalizeDouble, MathRound, etc.) there is "bug" on "specific" numbers, therefore ... numbers didnot became rounded.
5763

dzfx5:

LOL.. ok, i give up :D :D :D
(if you dont hear me)

Comment to "ALREADY rounded to 2 digits" -> this is problem, cos it wasn't actually rounded..
cos simetimes using defided funtions there is "bug" ... not actually rounding numbers LOL

It was rounded or were you blind and missed the part where he showed his code for rounding? You really are insistent! Stop it!

15

Fernando Carreiro:

It was rounded or were you blind and missed the part where he showed his code for rounding? You really are insistent! Stop it!

Questions is - why post author posted this post if he knows all defined funtions?

I want say ->  NormalizeDouble  dont actually round ALL numbers correctly, therefore this post author also gets wrong results.

Cos problem actually is simple -> just round your output corectly (dont always trust NormalizeDouble).

5763

dzfx5:

Questions is - why post author posted this post if he knows all defined funtions?

I want say ->  NormalizeDouble  dont actually round ALL numbers correctly, therefore this post author also gets wrong results.

Cos problem actually is simple -> just round your output corectly (dont always trust NormalizeDouble).

Dam it! He did not use "NormaliseDouble" at all! Stop arguing things that simply are not relevant to the OPs question. Stop being so arrogant!
15

Fernando Carreiro:
Dam it! He did not use "NormaliseDouble" at all! Stop arguing things that simply are not relevant to the OPs question. Stop being so arrogant!

ok, i dont need it - i just wanted to help ;)
(but my unswer to this post is, before you made output "ANYWERE" is) ->

//------------------------------

double BarVolAvg = 10694990411.760000;
BarVolAvg = (MathFloor(BarVolAvg * 100)) / 100;
BarVolAvg = NormalizeDouble(BarVolAvg, 2);
printf("BarVolAvg = " + BarVolAvg);
//-------------
BarVolAvg = 10694990411.76;

Only than use ->

`IndicatorSetInteger( INDICATOR_DIGITS, _Digits );`
(function from "dictionary");
15

....
Acutally I see where is problem, but you dont (there is difference) :D
(dont look at my posts amount in MQL community, cos im just registered - and it look's like its not good to help others in messages at all, cos moderators and other users "jumps on me" (cos i use just nornal programmer's "life hacks", cos you dont know that im 15 years experianced PHP/MySQL programmer anyways (not in MQL, where is some possible differences, but main way how you make decisions dont differs many anyways)).
Moderator
30420

dzfx5:

ok, i dont need it - i just wanted to help ;)
(but my unswer to this post is, before you made output "ANYWERE" is) ->

//------------------------------

```double BarVolAvg = 10694990411.760000;
BarVolAvg = (MathFloor(BarVolAvg * 100)) / 100;
BarVolAvg = NormalizeDouble(BarVolAvg, 2);
printf("BarVolAvg = " + BarVolAvg);
```

//-------------
BarVolAvg = 10694990411.76;

Let's just show how your code is not reliable (apart from being off topic).

BarVolAvg is a calculated value and it is extremely unlikely that it will always be calculated to a nice convenient 2 fractional digits.

Such as

10694990411.760000

What if it was calculated to

10694990411.759999    ?

Now, if you wanted to display that to 2 fractional digits you'd want it displayed as

10694990411.76

Wouldn't you?

So let's try that with your code

```double BarVolAvg = 10694990411.759999;
BarVolAvg = (MathFloor(BarVolAvg * 100)) / 100;
BarVolAvg = NormalizeDouble(BarVolAvg, 2);
printf("BarVolAvg = " + BarVolAvg);```

It prints as

10694990411.75

Not really the wanted result is it?