FI data type NOT operator?
1 次查看(过去 30 天)
显示 更早的评论
I am trying to take the BITNOT of an FI data type. For example if I have the following code:
tst = fi(5, numerictype(0,4,0));
How would I get the bitwise NOT of 5 (which should be hex A, or 10)? The ~ operator is the logical not, and is not what I need. I have searched the documentation, and maybe I missed it, but there does not seem to be anything in the BITWISE operators section. Am I just going nuts? Is the only way to do this do use a for loop with the BITSET/BITGET commands?
Thanks.
0 个评论
采纳的回答
Walter Roberson
2011-7-21
Maxval = fi(15, numerictype(0,4,0));
bitnot5 = bitxor(Maxval, tst);
I do not know why there is no specific bitnot(), but this is a common transformation, bitwise_not(value) = xor(all_ones, value)
更多回答(1 个)
Kaustubha Govind
2011-7-22
You can use BITCMP:
tst = fi(5, numerictype(0,4,0))
tst_not = bitcmp(tst)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Entering Commands 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!