visual c++ - how do I get this code to take 65 and convert it into binary with c++/cli -
this question has answer here:
- decimal binary 11 answers
private: system::void button1_click(system::object^ sender, system::eventargs^ e) { int base10; long base2 = 0; base10 = convert::toint32(txtbase10->text); base2 = base10 / 128 * 10000000; base10 %= 128; base2 = base10 / 64 * 1000000; base10 %= 64; base2 = base10 / 32 * 100000; base10 %= 32; base2 = base10 / 16 * 10000; base10 %= 16; base2 = base10 / 8 * 1000; base10 %= 8; base2 = base10 / 4 * 100; base10 %= 4; base2 = base10 / 2 * 10; base10 %= 2; base2 = base10 / 1 * 1; base10 %= 1; }
you not understand binary form of numbers. if need convert integer it's string represenation may following:
string base2 = convert.toint32(str,2).tostring(); string base8 = convert.toint32(str,8).tostring(); string base10 = convert.toint32(str,10).tostring(); string base16 = convert.toint32(str,16).tostring();
Comments
Post a Comment