[英]Decimal from a char* to binary
I have a string that consists some decimal value, with number of digits can be more than any existing int-types can hold(I know the number of digits). 我有一个包含一些十进制值的字符串,其位数可以比任何现有的int类型都要多(我知道数字的位数)。 Give me some hints, please, how can I convert that number to it's binary representation (so I will have other char* variable, that will consist binary).
请给我一些提示,请问如何将该数字转换为二进制表示(因此我将使用其他char *变量,它将包含二进制)。
您可以使用类似GNU Multiple Precision库的东西,它支持很长的数字。
Just some hints (if you want to implement it by hand). 只是一些提示(如果你想手动实现)。
I did that (homework) this way: 我这样做(作业):
(I don't know if there are better or faster solutions.) I won't post the code, this way you can enjoy to do it yourself ;) (我不知道是否有更好或更快的解决方案。)我不会发布代码,这样你就可以享受自己做的;)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.