十进制转二进制

//假定数据类型是int 

        static string GetBin(int n) { string result = ""; do { result = (n % 2 == 0 ? "0" : "1")+result; n = n / 2; } while (n > 0); return (new string('0',sizeof(int)-result.Length))+result; }


posted on 2010-05-29 19:14  林大虾  阅读(297)  评论(0编辑  收藏  举报

导航