bitshift Double inputs error

9 ビュー (過去 30 日間)
Lefteris Kostakis
Lefteris Kostakis 2019 年 11 月 24 日
編集済み: Lefteris Kostakis 2019 年 11 月 24 日
I use this command where A is a 4x4 array and "s" is a dobule (actually it's value is 18.000)
I assume the inputs as int64, then why I get error "Double inputs must have integer values in the range of ASSUMEDTYPE" ?
W = bitshift(A,s-15,'int64');
whos A prints: " A 4x4 128 double "
Edit: I changed the command to "W = bitshift(int64(A),int64(s-15),'int64');"
But is the way to do it ?

採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 11 月 24 日
編集済み: KALYAN ACHARJYA 2019 年 11 月 24 日
A=randi(10,[4 4]);
s=18;
W = bitshift(A,s-15,'int64')
Result:
W =
40 56 32 72
32 16 80 72
64 8 80 48
64 48 24 72
Documentation: If A is an array of signed integers, then bitshift returns the arithmetic shift results, preserving the signed bit when k is negative, and not preserving the signed bit when k is positive.
See simmilar question here

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOperators and Elementary Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by