C = bitget(A, bit) range limit

17 ビュー (過去 30 日間)
Yun Xiao
Yun Xiao 2012 年 6 月 1 日
Why the bitget range is only 1-52 bit, not covering 64 bit numbers?
Is a simple way to get around that? If I want to check a bit of any 64 bit number?
>> bitget(hex2dec('FFFFFFFF'),52) = 0
>> bitget(hex2dec('FFFFFFFF'),53)
??? Error using ==> bitget; BIT must be integers between 1 and 52 for double.
>> bitget(hex2dec('1FFFFFFFFFFFFF'),52) =1
>> bitget(hex2dec('20000000000000'),52)
??? Error using ==> bitget; Exceeded value of bitmax.

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 6 月 1 日
It might depend upon the release you are using, but in current releases bitget is not restricted to 52 bits.
Your major problem at the moment is that hex2dec() outputs a double precision number.
Try
bitget( sscanf('FFFFFFFF', '%lx'), 53)

カテゴリ

Help Center および File ExchangeModify Image Colors についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by