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?
相关问题
- Do the Java Integer and Double objects have unnece
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- back button text does not change
- Index of single bit in long integer (in C) [duplic
相关文章
- 现在使用swift开发ios应用好还是swift?
- TCC __TCCAccessRequest_block_invoke
- xcode 4 garbage collection removed?
- Unable to process app at this time due to a genera
- How can I add media attachments to my push notific
- didBeginContact:(SKPhysicsContact *)contact not in
- Custom Marker performance iOS, crash with result “
- Why is my library not able to expand on the CocoaP
Using
NSMutableData
you can fetch the byte in achar
, shift your bits and replace it with-replaceBytesInRange:withBytes:
.I don't see any other solution except for writing your own date holder class using a
char *
buffer to hold the raw data.As you'll have spotted, Apple doesn't provide arbitrary precision support. Nothing is provided larger than the 1024-bit integers in vecLib.
I also don't think
NSData
provides shifts and rolls. So you're going to have to roll your own. E.g. a very naive version, which may have some small errors as I'm typing it directly here:Of course, that assumes the number of bits you want to shift by is itself expressible as an
NSUInteger
, amongst other sins.