• 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.

Double, unsigned int and 64-bit (unsigned) int in JASS?

Status
Not open for further replies.

Deleted member 219079

D

Deleted member 219079

How would I go about implementing each of those, with addition, subtraction, division and multiplication and then casting from type to another?
 

Dr Super Good

Spell Reviewer
Level 65
Joined
Jan 18, 2005
Messages
27,290
You would need to do it in a similar what that such types are implemented on low power microprocessors. For both double and long long int I would recommend a pair of integer variables to represent them, one being the low word and the other the high word of the number. You then need to use the available logic of the integer to emulate the necessary logic on both the integers representing a larger integer. Seeing how JASS lacks bitwise operators this can end up quite slow as those have to be emulated as well with lookup tables.

Sadly I cannot find resources explain the emulation algorithms. Some are quite simple such as addition and subtraction. Others are painfully hard like division or sine/tan/power/log.
 
Level 6
Joined
Jul 30, 2013
Messages
282
Well you got modulus... tho its slow but at least its a 1 liner.... so you dont need a whole lib for it.. and its in blizzard.j

you could do stuff like split an int in 2 with not too much trouble if you can get the modulus.

not sure if having divides and multiplies as part of simple addittion can be called satisfactory tho.
its prolly better than whatever ppl do for true bitwise operations tho, ive seen libraries that like have libraries that got sub libraries just for what should be a 1 cycle op on any cpu horrible...
 

Dr Super Good

Spell Reviewer
Level 65
Joined
Jan 18, 2005
Messages
27,290
its prolly better than whatever ppl do for true bitwise operations tho, ive seen libraries that like have libraries that got sub libraries just for what should be a 1 cycle op on any cpu horrible...
You will be surprised how fast those complex bitwise operators are, at least compared to anything involving division or multiplication. Ultimately they use lookup tables and a lot of micro optimizations. Not 1 cycle, but still better than nothing.
 
Status
Not open for further replies.
Top