Problems with conversión

 
Good morning, I have a little problem, and I need help ...
I have two variables
int a = 09;
int b = 05;

I need to concatenate these two variables for what do I convert a string and concatenation, the result is

95 (I lose the leading 0)

then turn back to Integer and I need to make a comparison, but of course the result is bad because I need the 0 for the comparison is correct, how I can do to keep these leading 0?.

Thank you.
 
  1. There are no leading zeros in ints. There's no need to keep it. There's no need to concatenate for comparison. Define what you mean by your comparison. What are you trying to do?

  2. int a = 09;
    int b = 05;
    int a = 9;
    int b = 5;
    In mt4 these are EXACTLY the same. There is NO difference. (in C/C++ the leading zero means octal conversion, 05==5, 09 doesn't compile, and 011==8+1==9)
 
jugivi:
Good morning, I have a little problem, and I need help ...
I have two variables
int a = 09;
int b = 05;

I need to concatenate these two variables for what do I convert a string and concatenation, the result is

95 (I lose the leading 0)

then turn back to Integer and I need to make a comparison, but of course the result is bad because I need the 0 for the comparison is correct, how I can do to keep these leading 0?.

Thank you.

Just think a little, it's very simple . . .

int a = 09;
int b = 05;

string LeadingZero_a, LeadingZero_b;

LeadingZero_a = "", LeadingZero_b = "";

if( a < 10 ) LeadingZero_a = "0";
if( b < 10 ) LeadingZero_b = "0";

Print( "Concatenated string with leading zeros: ", StringConcatenate(LeadingZero_a, a, LeadingZero_b, b) );
 
If all the OP wanted was to add a leading zero, that's easy, your IF or my RJust
string   RJust(string s, int size, string fill=" "){
   for(int n=size-StringLen(s); n > 0; n--)  s = fill+s;    return(s);        }
:
   Print( "a=", RJust(a, 2, "0"), " b=", Rjust(b, 2, "0") );
But he was also talking about comparison.