bitshift Double inputs error

9 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Operators and Elementary Operations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by