• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[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:

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
@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