Python灰码直接保存为小数
我正在为一个Python项目工作,我想知道是否可以使用以下内容:
当前,我有一个以字符串为单位的灰色码:“ 1000”,我想将其转换为IS INSEGER(DECIMAL,BASE 10)值 - > 15
Im working for a python project and i wonder if the following is possible:
Currently I have a graycode stored as an string i.e: "1000" and I want to convert it to is integer (decimal, base10) value --> 15
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
来自 rosettaCode :
这以
int
int 作为输入,所以在调用函数之前,您必须分析字符串:From RosettaCode:
This takes an
int
as input, so you would have to parse the string before calling the function:下表显示了将二进制代码值转换为灰色代码值的转换:
尝试此代码
从十进制到灰色代码
从灰色代码到小数的
来源: geeksforgeeks
The following table shows the conversion of binary code values to gray code values:
Try this code
FROM DECIMAL TO GRAY CODE
FROM GRAY CODE TO DECIMAL
source : geeksforgeeks
有一个很好的例子在这里
要点是:
there is a good example here
the gist is: