Download MetaTrader 5

Print Decimal Number With Defined Number of Characters

To add comments, please log in or register
Marcos Silva
358
Marcos Silva  

Im looking to print the following

value :3  as 00003

value :124 as 00124

value :8324 as 08324

in this case it would be 5 characters.. 

is it possible?

Thanks             
 

Carl Schreiber
6689
Carl Schreiber  
Look in the reference for PrintFormat() of StringFormat().
JD4
1101
JD4  

Do you mean you want decimals as in your value 3 is actually .00003, or you want 3 with leading zeros that would normally not be there?

It makes a difference.  But, if you want to output stuff, you need to convert your data to a string in some way.

Here are some doc links to get you started.

Conversion Functions

String Functions

Common Functions

whroeder1
14779
whroeder1  
PrintFormat("%05d", 3); // 00003
Marcos Silva
358
Marcos Silva  

Got it suiting my needs using:

 int number = 3;

 string NumbWith6Digits =  IntegerToString(number,6,'0'); 

Marcos Silva
358
Marcos Silva  
Thank You guys!
To add comments, please log in or register