is there a built in function to get minimum nr of bits for an integer ?

조회 수: 2 (최근 30일)
timo
timo 2016년 10월 2일
댓글: dpb 2016년 10월 2일
I have found the formula for minimum nr of bits for a integer
bspec = floor(log2(16)) + 1
Is there a built in function for this in MATLAB ?
  댓글 수: 1
dpb
dpb 2016년 10월 2일
When you write one, there will be... :)
But, what do you need a function for a constant; unless you intended the argument '16' to be a variable based on the length of a word???
If the object is to find out the size of an integer, see
doc class
doc isa

댓글을 달려면 로그인하십시오.

답변 (1개)

Peng Liu
Peng Liu 2016년 10월 2일
Not floor(log2(x)) + 1 but ceil(log2(x)) is correct

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by