• 🏆 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!

[Solved] Decimals for Integer Variables?

Status
Not open for further replies.
Level 4
Joined
May 2, 2009
Messages
69
Hey folks,

This probably has a very simple answer and I'm just looking in the wrong places:

Am I able to set it so I can input decimals for Integer Variables, and how?​

I've looked in the preferences and in all the tabs in the Trigger Editor...
Help would be appreciated! :goblin_cry:
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
You can use fixed point to represent a fractional quantity in an integer. This involves converting the least significant bits into fractional bits by equivalently dividing the place value of each bit by some power of two. StarCraft II uses their "fixed" type which is their equivalent to a Real.

Obviously converting an integer to fixed will reduce the maximum representable range appropriately. The only time you should use fixed point is for platform independency, fixed accuracy and speed. Floats, another way of representing fractional data, are mostly platform dependant, have varying accuracy with number complexity and are computed considerably slower than integers on most hardware.

For the most part a fixed value is treated exactly the same as a standard integer. Most operations such as addition, subtraction, bit shifts (if jass had any) all are computed the same. The only major time it has to be treated differently are with special functions (sine, cosine etc) and when printing in readable form as the decimal conversion has to specifically treat each bit with the correct value.

Nothing stops you using fixed in JASS (Warcraft III). Many people often use it un-aware they are actually using such a system. A simple example could be updating a unit position 64 times a second with a counter keeping track of the number of updates. You can convert this to whole seconds by dividing by 64, which if done using float values (as there is no way to print it in decimal otherwise) will give you a fractional value.
 
Status
Not open for further replies.
Top