We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在实际应用中,经常需要使用到数的进制转换,虽然现在许多语言都提供了相应的方法直接进行进制转换,但是作为一个工科gay,还是必须知道常见的进制转换的实现原理的~
0
1
42
0~7
0~9
a-f
计算两个数的汉明距离
let hammingDistance = (x, y) => { let distance = 0; while (x != 0 || y != 0) { // 当某一个数的商为0时,二进制比较结束 if (x%2 != y%2) { // 二进制逐位比较 distance++; } x = Math.floor(x/2); // 获取商 y = Math.floor(y/2); // 获取商 } return distance; };
The text was updated successfully, but these errors were encountered:
1010-0001=1001 图中算错了。。。
Sorry, something went wrong.
No branches or pull requests
在实际应用中,经常需要使用到数的进制转换,虽然现在许多语言都提供了相应的方法直接进行进制转换,但是作为一个工科gay,还是必须知道常见的进制转换的实现原理的~
十进制转为二进制
0
和1
0
或1
时为止,然后在旁边标出各步的余数,最后倒着写出来,高位补零,就完成了42
转为二进制为例二进制转为十进制
十进制转八进制
0~7
表示十进制转十六进制
0~9
以及a-f
表示二进制与八进制互转
扩展阅读
计算两个数的汉明距离
The text was updated successfully, but these errors were encountered: