• 🏆 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] BitInt

Level 31
Joined
Jul 10, 2007
Messages
6,306
This is completely different from BigInt ; )

bits are written, so you don't multiply and add like you did before, you just write bits

because bits are written, the size is going to bloat a bit. The multiply in BigInt lets you store with maximal accuracy, down to fractions of bits. When you just use bits directly, you lose that accuracy, thus bloat. However, BitInt is MUCH faster than BigInt and as such can handle MUCH more data w/o freezing or thread crashing. The operation magnitudes are also independent from the number of bits in a BitInt, unlike BigInt, whose operations grow as the BigInt grows.

You want to use BigInt when you are dealing with standard save/load codes and BitInt when you are doing save/load with networking.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Added 4 new methods
JASS:
*           //dangerous, read note
*           method pushFront takes BitInt bits returns nothing
*               -   Pushes bits on to front of this
*               -   Can push on to partials, but can't push parials
*               -   A BitInt is partial if bitCount%bitGroup != 0
*
*           //dangerous, read note
*           method pushBack takes BitInt bits returns nothing
*               -   Pushes bits on to back of this
*               -   Can push partials, but can't push on to partials
*               -   A BitInt is partial if bitCount%bitGroup != 0
*
*           method popFront takes integer nodeCount returns BitInt
*               -   Pops off front nodes and returns BitInt containing them
*
*           method popBack takes integer nodeCount returns BitInt
*               -   Pops off back nodes and returns BitInt containing them
 
Level 4
Joined
Jun 26, 2013
Messages
48
math? no, never heard...

Code:
// cJass
#define IntGetByte1(src) = (src / (256*256))
#define IntGetByte2(src) = (ModuloInteger(src, (256*256)) / 256)
#define IntGetByte3(src) = (ModuloInteger(src,256))
#define IntSetByte1(src,val) = { src = (ModuloInteger(src,(256*256)) + val*256*256 ) }
#define IntSetByte2(src,val) = { src = (ModuloInteger(src,256) + (src / (256*256))*256*256 + val*256) }
#define IntSetByte3(src,val) = { src = ((src / 256)*256 +val)}

Hello from Russia
 
math? no, never heard...

Code:
// cJass
#define IntGetByte1(src) = (src / (256*256))
#define IntGetByte2(src) = (ModuloInteger(src, (256*256)) / 256)
#define IntGetByte3(src) = (ModuloInteger(src,256))
#define IntSetByte1(src,val) = { src = (ModuloInteger(src,(256*256)) + val*256*256 ) }
#define IntSetByte2(src,val) = { src = (ModuloInteger(src,256) + (src / (256*256))*256*256 + val*256) }
#define IntSetByte3(src,val) = { src = ((src / 256)*256 +val)}

Hello from Russia

That's not relevant to this resource and the use of ModuloInteger would get us closer to the operation-limit. (Meaning MD5 and AES wouldn't work well :v)
Also, that code has the wrong behavior for negative numbers.
 
Level 4
Joined
Jun 26, 2013
Messages
48
That's not relevant to this resource and the use of ModuloInteger would get us closer to the operation-limit. (Meaning MD5 and AES wouldn't work well :v)
Also, that code has the wrong behavior for negative numbers.

I didn't create SetByte4 but you can if you want, this is not too difficult.

To solve oplimit you can use 1 periodic timer with custom stack (ExecuteFunc leads to desync, tested), this is not a problem at all.
 
Level 4
Joined
Jun 26, 2013
Messages
48
Magtheridon96, ok, I meant the oplimit resolution should be incapsulated into MD5 system and you can call MD5 without worrying about threads.

Nestharus, the question is in perfomance of your overheaded OO according binary operations. Nobody in pro dev does such kinda things. But in pro langs there are good optimizators and directives (like marco and inline) for such kinda calls, what I cannot say about vjass =)
 
Top