FI data type NOT operator?

1 Ansicht (letzte 30 Tage)
Sean Little
Sean Little am 21 Jul. 2011
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.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 21 Jul. 2011
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 Kommentar
Sean Little
Sean Little am 21 Jul. 2011
I should have caught that trick. Thanks or the tip. But I really think there should be a BITNOT command.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Kaustubha Govind
Kaustubha Govind am 22 Jul. 2011
You can use BITCMP:
tst = fi(5, numerictype(0,4,0))
tst_not = bitcmp(tst)

Kategorien

Mehr zu Entering Commands finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by