Rounding numbers in MT4 via NormalizeDouble - page 6

 
Roman Starinskij:

That's how it works! Thank you. I normalise to 3 digits and then trim the extra digits after the decimal point.

Can you tell me if there is a standard function to trim H digits after the decimal point? Like StringSubStr only if it is a fractional number.

Trimai.

extern ushort Characters_delete = 1;


////////////////////////////////////
string resoult="";  
string data=DoubleToString(Bid,Digits); 
int lenth=StringLen(data);


for(int i=0;i<lenth-Characters_delete;i++)
{
StringAdd(resoult,StringSubstr(data,i,1));
}
 
Vasyl Nosal:

Trimai.

Couldn't you come up with a more convoluted way?

The best way is to use DoubleToStr() with one extra character, and use StringSubstr() to discard the last character.

 
Dmitry Fedoseev:

Couldn't you come up with a more convoluted way?

The best way is to use DoubleToStr() with one extra character, and use StringSubstr() to discard the last character.

The code?
 
Vasyl Nosal:

Trimay.

Couldn't have done any better. Lines are terribly slow.

There are special functions

 
Vasyl Nosal:
Code?
Do it yourself.
 
Victor Nikolaev:

Couldn't have done any better. Lines are terribly slow.

There are special functions

Code?
 
Dmitry Fedoseev:
Do it yourself.
That's what I thought.
 
Vasyl Nosal:
That's what I thought.
What's there to laugh about. I wish there was something to do.
 
Vasyl Nosal:
Code?

What code.

Multiply by a factor, take the minimum integer. divide by a factor

 
Victor Nikolaev:

What code.

Multiply by a factor, take the minimum integer. divide by a factor

No, not that one. This one is"DoubleToStr() with one extra sign, and use StringSubstr() to discard the last sign".