News:

  • July 03, 2026, 01:24:03 AM

Login with username, password and session length

Author Topic: Inverting WORD level and DWORD level bits in DM  (Read 12905 times)

MAEdwards

  • Sr. Member
  • ****
  • Posts: 56
Inverting WORD level and DWORD level bits in DM
« on: March 25, 2015, 03:03:14 PM »
Greetings!

I am still very new to the forum, but I've already discovered several very sharp cats on here.  I'll spare each of you some blushing by NOT calling you out by username.

I've been using DirectSoft5 for about 3 years now, and often AND, OR, XOR, Invert, ORStack, ANDStack on a WORD or DWORD Level.

With the Do-More, I believe that I can accomplish a lot of my AND's, OR's, XOR's in the Math Boxes.  However, I haven't stumbled across any INVERT instruction that would allow me to invert the bit statuses in a WORD or DWORD.

Example:
Input: 1001
Process: Invert
Output: 0110

I am sure there is something already in place, but it eludes me right now.  Thoughts?

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6164
  • Yes Pinky, Do-more will control the world!
Re: Inverting WORD level and DWORD level bits in DM
« Reply #1 on: March 25, 2015, 03:07:09 PM »
'~' in a MATH box...e.g. ~D0 will return 0xFF00FF00 if D0=0x00FF00FF.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

MAEdwards

  • Sr. Member
  • ****
  • Posts: 56
Re: Inverting WORD level and DWORD level bits in DM
« Reply #2 on: March 25, 2015, 05:38:01 PM »
Bob,

So "~Register"(no quotes)  is the acting invert instruction?  Thank you so much.  I will give this a shot this week.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6164
  • Yes Pinky, Do-more will control the world!
Re: Inverting WORD level and DWORD level bits in DM
« Reply #3 on: March 25, 2015, 06:04:02 PM »
Bob,

So "~Register"(no quotes)  is the acting invert instruction?  Thank you so much.  I will give this a shot this week.

That is correct.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3833
    • Host Engineering
Re: Inverting WORD level and DWORD level bits in DM
« Reply #4 on: March 26, 2015, 08:38:27 AM »
So "~Register"(no quotes)  is the acting invert instruction?  Thank you so much.  I will give this a shot this week.

It's just a unary operator, like negate.  So it works on an expression.  So you could do ~(V0 + V1) just like you could do -(V0 + V1).

Do-more's MATH expression utilizes C/C++/Java/PHP MATH operator syntax.  So Bitwise AND is a single &, Logical AND is a double &&.  All of the functions/operators are documented in the MATH - Calculate Expression Help Topic DMD0085.

MAEdwards

  • Sr. Member
  • ****
  • Posts: 56
Re: Inverting WORD level and DWORD level bits in DM
« Reply #5 on: March 26, 2015, 09:23:49 AM »
So "~Register"(no quotes)  is the acting invert instruction?  Thank you so much.  I will give this a shot this week.

It's just a unary operator, like negate.  So it works on an expression.  So you could do ~(V0 + V1) just like you could do -(V0 + V1).

Do-more's MATH expression utilizes C/C++/Java/PHP MATH operator syntax.  So Bitwise AND is a single &, Logical AND is a double &&.  All of the functions/operators are documented in the MATH - Calculate Expression Help Topic DMD0085.

Franji1,

Thank you so much.  I looked in the help file previously, but had looked for an inverting instruction in the BINARY OPERATORS section and/or searched for INV or INVERT.  I missed the UNARY OPERATORS. 

I appreciate the help.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3833
    • Host Engineering
Re: Inverting WORD level and DWORD level bits in DM
« Reply #6 on: March 26, 2015, 10:03:14 AM »
I looked in the help file previously, but had looked for an inverting instruction in the BINARY OPERATORS section and/or searched for INV or INVERT.
Yes, that's a terminology ambiguity that is VERY easy to get backwards.

There are Binary vs. Logical operations.  One works at the bit level, the other works at true/false non-zero/zero level.  Logical-and(&&) is a logical operation.  Bit-wise-and(&) is a binary (or bit) operation.

There are Binary vs. Unary operators.  Add(+), Subtract(-), Multiply(*), Divide(/) are binary operators.  Negate(-), Invert(~), Not(!) are unary operators.  Note that both Bit-wise(binary)-and(&) and logical-and(&&) are both binary operators.  (Confused yet?  I know I am!)

So, bit-wise-and(&) is both a binary operator and a binary (bit) operation (really?).

The Help groups the specific MATH features across multiple tables: Binary operators, Unary operators, and then all the various Named-Function groups.  There are Binary (bit) operations in both the Binary operator table and Unary operator table  :-\.

Sounds like we need to re-group the binary/unary operators based on FUNCTION, not GRAMMAR TYPE.  Doh!

MAEdwards

  • Sr. Member
  • ****
  • Posts: 56
Re: Inverting WORD level and DWORD level bits in DM
« Reply #7 on: July 22, 2015, 09:04:28 AM »
Franji1,

That was an absolute mouth full.  Haha.
Thanks for the explanation.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3833
    • Host Engineering
Re: Inverting WORD level and DWORD level bits in DM
« Reply #8 on: July 22, 2015, 05:03:40 PM »
Thanks for the explanation.
If you look in Designer 1.4 Help that just shipped, the MATH help topic tables have been re-grouped:

Arithmetic Operators (+ - * / etc.)
Binary/Bit-wise Operators (& | ^ etc.)
Logical Operators (>= && || etc.)
Common Functions (ABS MAX etc.)
Real Functions (E FRAC LN etc.)
Trigonometric Functions (SIN COS TAN etc.)
Statistical Functions (AVGR STDEVR RANDINT etc.)
Conditional Functions (IF COUNTIFEQ SUMIFGE etc.)
Time Functions (NOW TICKus TICKms)
(Indirect) Memory Access (REF array-index-expression)

MAEdwards

  • Sr. Member
  • ****
  • Posts: 56
Re: Inverting WORD level and DWORD level bits in DM
« Reply #9 on: July 27, 2015, 12:49:44 PM »
Thanks, Franji1