Print Decimal Number With Defined Number of Characters

Back to topics list To post a new topic, please log in or register
avatar
59
investguy 2015.07.20 17:24
 

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             
 

avatar
2017
gooly 2015.07.20 18:28 #
 
Look in the reference for PrintFormat() of StringFormat().
avatar
313
JD4 2015.07.20 18:32 #
 

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



avatar
12985
WHRoeder 2015.07.20 19:52 #
 
PrintFormat("%05d", 3); // 00003
avatar
59
investguy 2015.07.20 20:26 #
 

Got it suiting my needs using:

 int number = 3;

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

 

avatar
59
investguy 2015.07.20 20:27 #
 
Thank You guys!
Back to topics list  

To add comments, please log in or register