Floor function for int8
Show older comments
I want to round down (floor) variable defined as int8 without converting to double !
for example: a=int8(8.6);
I want the result will equal to 8 instead of 9. Is there way to do or it impossible (without converting to double) ? The reason I need it, because I work with large matrix (25000x25000) of int8.
Thanks Alex
2 Comments
Walter Roberson
on 1 Aug 2011
To check the circumstances: do you have something like
int8(86) ./ int8(10)
and you want the result to be int8(8) instead of int8(9) ?
Alexander Brodsky
on 1 Aug 2011
Accepted Answer
More Answers (2)
Sean de Wolski
on 1 Aug 2011
A = int8(magic(10));
B = int8(5);
idx = (mod(A,B)>(B/2)); %elements that need to be reduced.
C = A./B;
C(idx) = C(idx)-1;
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!