正整数转成二进制,除以2取余数‘然后倒序排列 将正的十进制数除以二,得到的商在除以二,以此类推直到商为零或一时为止 然后在边上表上各步的余数,最后倒这写出来就可以
42 除以2 得到的余数分别为010101,然后倒着排一下 ,42对应的二进制就是101010
整数二进制转换十进制:首先将二进制数补齐位数 ,首位如果是0就代表是正整数,如果首位是一就是负整数。将二进制中的位数分别将 将下边对应的值相乘,然后相加得到的就为十进制比如1010转换为十进制
If the first digit of the binary complement is 1, you need to reverse the conversion: for example, 1110111, and the first digit is 1, then reverse it -00010100, and then calculate the decimal system corresponding to 10100 as 20, so the corresponding decimal system is -20