here's an algorithm for you set your string all to "0"
the string has 8 slots representing 8 bits from the right slot to the left slot incrementing by 1 position at a time --- put the remainder of a modulus 2 into the slot stop when the number you're dividing is zero. For example, the number 3 textBoxSlot1->Text = "00000000" 3 modulus 2 is 1 text is now "00000001" your number becomes 1 1 modulus 2 is 1 make the text "00000011" the number becomes zero STOP! OR.... get the length of string that is made by your operation, call that str_len_1 textBoxSlot1->Text = Convert::ToString(a_high ,2) create a string of 0's the length of 8 - str_len_1, put that in str_zero. Then concatenate them. textBoxSlot1->Text = str_zero + Convert::ToString(a_high ,2) On 4 September 2010 08:44, Giox <[email protected]> wrote: > Good morning, I have a problem that I think is quite simple, but I'm > not able to fix it by my self. > > I have two eight bit numbers, suppose: > > a_low = 3 > a_high = 2 > > I would like to create a string like the following one: > > 00000010 00000011 > > But I'm not able to force the left padding of the number. > I'm acting as follows: > > textBoxSlot1->Text = Convert::ToString(a_high ,2)+ > Convert::ToString(a_low ,2); > > However by this way I don't get the left padding with 0. > I tried using String::Format, but I don't know how. > Any help will be apreciated -- Charles A. Lopez [email protected] What's your vision for your organization? What's your biggest challenge? Let's talk. (IBM Partner)
