tags:

views:

80

answers:

3

I need to get the BIT length from NSUinteger or NSString

How i can get the bit length?

Thanks

+3  A: 

If I'm understanding the question correctly (it is kind of odd, but... hey... so am I):

sizeof(NSUInteger) * 8

[aString maximumLengthOfBytesUsingEncoding: ...] * 8

For NSNumber, a subclass of NSValue, things get a little bit trickier. You'll need to call -objCType, then determine the bit length from that.

bbum
A: 

OP: I really think you need to organize your thoughts and ask a single, coherent question that, at a minimum, gives an overview of what you're trying to accomplish. So far you have asked at least four questions that are all minor variations of each other.

To other people answering this question: From the context of his other questions, he's trying to do some bignum crypto (ala RSA), or some other bignum number theory stuff (needs to do powermod()). Again, based on the context of his other questions, what he's asking in this question is how to do floor(log2(X)) + 1 where X is an arbitrary data type (hence the NSString).

johne
I don't know how we're supposed to divine that from his question above, but I've added a comment to the question to clarify. If the asker hopes for a correct answer, they should provide a clearer question.
Quinn Taylor
A: 

I have a RSA Exponent key value which is supposed to be a biginteger but i have it in NSString/NSdata with full value in(UTF8 encoded)

As Part of RSA encryption , i need to do the following in the Iphone Env 1.I need to find the bit length of the above exponent value 2.I need to do arithmatic operations on exponent and modulus values including PowMod 3.so which data type i can use (uint64_t or NSNUmber or NSUinteger) for arithmatic operations as well as holding the bigint result value. 4.do i need to go for a specfic bigint implementation, can i able to manage with the above existing iphone data types for bigint ? 5. those external bigint implementations expect to port openssl or gmp lib to Iphone ?