如何在Char上执行算术运算 [英] How Do I Perform Arithmetic Operations On Char
本文介绍了如何在Char上执行算术运算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
i需要创建一个处理多个精确数字的类
我需要将这个新类型表示为char,
例如'214587954'
i需要将每个数字转换为添加的ASCII 4位的二进制数
这意味着我需要用4位代表每个数字
并在定义所有可用的运算符后
帮助请我甚至不知道从哪里开始
谢谢
hello
i need to create a class that deals with multiple precision numbers
and i need to represent this new type as char ,
for example '214587954'
i would need to convert each number into binary take of the added ASCII 4 bits
which means that i need to represent each number in 4 bits
and after define all the available operators
help please i don't even know where to start
thank you
推荐答案
请参阅我对该问题的评论。这不是应该如何实施的。传统上,这称为位整数或bitInt。您可以轻松找到合适的实施方案: http://bfy.tw/3PSZ [ ^ ]。
特别是,你可以在这里找到一个实现: https://gmplib.org [ ^ ]。
另一个在这里: http:// sourceforge。 net / projects / ttmath [ ^ ]。
-SA
Please see my comments to the question. This is not how such thing should be implemented. Traditionally, this is called "Bit integer" or "bitInt". You can easily find appropriate implementation: http://bfy.tw/3PSZ[^].
In particular, you can find one implementation here: https://gmplib.org[^].
Another one is here: http://sourceforge.net/projects/ttmath[^].
—SA
这篇关于如何在Char上执行算术运算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文