任意precision位操作(目标C) [英] Arbitrary precision bit manipulation (Objective C)
问题描述
我需要做的目的C.任意precision号到目前为止,我一直在使用NSData的对象持有的数字再presentations位操作 - 是有办法的内容位移位?如果没有,是否有不同的方式来实现这一目标?
I need to do bit operations on representations of arbitrary precision numbers in Objective C. So far I have been using NSData objects to hold the numbers - is there a way to bit shift the content of those? If not, is there a different way to achieve this?
推荐答案
使用 NSMutableData code>您可以获取的字节
字符
,改变你的位,并与 -replaceBytesInRange:withBytes:
。
Using NSMutableData
you can fetch the byte in a char
, shift your bits and replace it with -replaceBytesInRange:withBytes:
.
我看不到任何其他的解决方案,除了使用的char *写你自己的日期holder类
缓冲区来保存原始数据。
I don't see any other solution except for writing your own date holder class using a char *
buffer to hold the raw data.
这篇关于任意precision位操作(目标C)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!