bitshift Double inputs error

9 views (last 30 days)
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 ?

Accepted Answer

KALYAN ACHARJYA
KALYAN ACHARJYA on 24 Nov 2019
Edited: KALYAN ACHARJYA on 24 Nov 2019
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

More Answers (0)

Categories

Find more on Operators and Elementary Operations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!