MATLAB Answers

Find out number of bits needed to represent a positive integer in binary?

20 views (last 30 days)
Mohsin Shah
Mohsin Shah on 16 Aug 2017
Edited: Mohsin Shah on 16 Aug 2017
How to compute the bit length of a positive integer-the number of bits to represent a positive integer. For example, we have:
integer bits
0 1
1 1
2 2
3 2
4 3
5 3
6 3
7 3
8 4
9 4
How to compute the bit length of an arbitrary large integer?

  0 Comments

Sign in to comment.

Accepted Answer

Guillaume
Guillaume on 16 Aug 2017
Edited: Guillaume on 16 Aug 2017
trivially with log2 (and ceil).
I have no idea what from the cryptographic perspective mean. It's the same from any perspective. It's just basic maths.

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.