大数转换,ASCII到二进制 [英] Large number conversion, ASCII to binary

查看:80
本文介绍了大数转换,ASCII到二进制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个函数,它将一个大的ascii

数字,比如100个ascii数字转换为它的二进制表示。似乎我想要的evey算法是倒退的。 Normaly在

笔和纸张ascii到二进制转换之后,将从

开始减去可从给定的

数中减去的最大2的幂并且从左到右工作以1s和0s填充记忆。

在我的情况下,我真的不能做那个b / c 2的最大功率

适合我试图转换的数字太大,即使对于

64位int。


任何帮助,建议,示例代码都会大大降低。


ets假设我有一个char类型的数组,其中evey元素的值等于ascii数字中下一个数字的值。


非常感谢

I am trying to write a function which will convert a large ascii
number, say 100 ascii digits, to its binary representation. It seems
that evey algorithm I am trying to think of is backwards. Normaly in
pen and paper ascii to binary conversion one would start by
subtracting largest power of 2 that can be subtracted from the given
number and work from left to right filling memory up with 1s and 0s.
In my case I cant really do that b/c the largest power of 2 which
would fit into a number i am trying to convert is too large even for
64 bit int.

Any help, suggestions, sample code would be greatly apreciated.

ets assume I have an array of char type, evey element of which has a
value equal to the value of next digit in ascii number.

Thanks ahead

推荐答案

On Sun,2008年7月13日17:52:13 -0700(PDT),fermineutron

< fr ********** @ yahoo.comwrote:
On Sun, 13 Jul 2008 17:52:13 -0700 (PDT), fermineutron
<fr**********@yahoo.comwrote:

>我正在尝试编写一个函数这将转换一个大的ascii
数字,比如说100个ascii数字它的二进制表示。似乎我试图想到的evey算法是倒退的。 Normaly在
笔和纸ascii到二进制转换中,首先要减去可以从给定的
数中减去的2的最大幂,并从左到右填充内存以1s和0s。
在我的情况下,我真的不能做那个b / c 2的最大功率
适合我试图转换的数字太大,即使对于
64位int。

任何帮助,建议,示例代码都会有很大的偏见。

假设我有一个char类型的数组,evey元素的值等于
到ascii数字的下一个数字的值。
>I am trying to write a function which will convert a large ascii
number, say 100 ascii digits, to its binary representation. It seems
that evey algorithm I am trying to think of is backwards. Normaly in
pen and paper ascii to binary conversion one would start by
subtracting largest power of 2 that can be subtracted from the given
number and work from left to right filling memory up with 1s and 0s.
In my case I cant really do that b/c the largest power of 2 which
would fit into a number i am trying to convert is too large even for
64 bit int.

Any help, suggestions, sample code would be greatly apreciated.

ets assume I have an array of char type, evey element of which has a
value equal to the value of next digit in ascii number.



任何大数字图书馆应该提供您需要的工具。我赞成理查德希思菲尔德喜欢clint的bignum部分但是b
可能是因为它是我学过的唯一一个。

删除del电子邮件

Any of the "big number" libraries should provide the tools you need. I
happen to like the bignum part of clint by Richard Heathfield but that
may be because it''s the only one I''ve studied.
Remove del for email


fermineutron< fr ********** @ yahoo.comwrites:
fermineutron <fr**********@yahoo.comwrites:

我正在尝试编写一个函数,它将一个大的ascii

数字,比如100个ascii数字转换为它的二进制表示。
I am trying to write a function which will convert a large ascii
number, say 100 ascii digits, to its binary representation.



家庭作业?如果没有,请使用bignum库(最终将支付)。如果

这是家庭作业,如果你告诉我你的话,我会告诉你我的...


-

Ben。

Homework? If not, use a bignum library (it will pay eventually). If
it is homework, I''ll show you mine if you show me yours...

--
Ben.


7月14日,5:52 * am,fermineutron< free4tram ... @ yahoo.comwrote:


如果您的问题与某些生产代码有关,那么最好不要重新发明轮子并使用现有的库。如果用于

教学目的,你应该发布你的方法。
On Jul 14, 5:52*am, fermineutron <free4tram...@yahoo.comwrote:

If your problem is regarding some production code, then it''s better
not to re-invent the wheel and use some existing library. If it is for
pedagogical purpose, you ought to post your approach.


这篇关于大数转换,ASCII到二进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆