• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Snippet] Byte Not

This snippet is used to do the Bitwise NOT operation. It takes one byte, meaning you have to input a number in the range [0x00 ... 0xff].

JASS:
/***************************
*
*   ByteNot
*   v1.1.0.1
*   By Magtheridon96
*
*   - Used to perform the bitwise NOT 
*     operation for 8 bits. (1 byte)
*
*   API:
*   ----
*
*       function B_NOT takes integer byte returns integer
*           - Returns (~byte)
*           - The argument must be in the range [0x00 ... 0xff]
*
***************************/
library ByteNot
    
    constant function B_NOT takes integer byte returns integer
        return 0xff - byte
    endfunction
    
endlibrary

JASS:
/***************************
*
*   Not32
*   v1.0.0.1
*   By Magtheridon96
*
*   - Used to perform the bitwise NOT 
*     operation for integers. (32-bits)
*
*   API:
*   ----
*
*       function NOT32 takes integer int returns integer
*           - Returns (~int)
*
***************************/
library Not32
    
    constant function NOT32 takes integer int returns integer
        return -int - 1
    endfunction
    
endlibrary

Feel free to comment.
Or not. This thing is too simple for that.
 
Last edited:
@TriggerHappy dude, I don't even understand why anyone would release byte(...) or (...)byte whateva, as a separate resources. Meaby the idea was to spam jass resources section?

All of them should be uploaded as a single snippet, meaby call it: BitwiseOperations or smthing.

Think about users too: instead of them adding: require BitwiseOperations, instead they have to add: byte_and, _or, _not, _xor, _shifts and others. Suddenly we got 7-8 requirements instead of elegant set of functions.
 
Top