Do Integer variables have an upper limit? I wanna create a custom leveling system, in which a hero unit can reach lvl 200. To reach lvl 200, the unit requires 333474250 exp (in total). Is this possible to store in an integer variable, or should I downscale the numbers?
Integers are signed 32 bits (2,147,483,647 max). If you want really big numbers you can use multiple integers representing different orders of magnitude eg 1-999, 1000-999000 and 1,000,000-999,000,000 etc. and transfer between them using maths.
Rollback Post to RevisionRollBack
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
The galaxy int type is a standard 32bit two's compliment integer has the following range.
Min Value = -2,147,483,648
Max Value = 2,147,483,647
Since 333,474,250 is less than 2,147,483,647 then using an int should work.
Depending on the sort of mathematical operations one needs, one can easily implement a 64bit two's compliment integer using 2 int values (a low-word and a high-word).
With addition this is fairly straight forward to do. Add the two low-word values together to produce the result of the low-word and determine if an overflow occurred. Overflow occurs with addition when {both inputs are negative} or {1 input is negative, the other input is positive and the result is not negative}. Add the two high-words together and then if overflow had occurred with the low-words add an extra 1 value to the result to produce the high-word. This is fairly simple to compute.
Subtraction is a similar idea and in worst case could be implemented using addition and negation of a number.
Multiplication and division are not so simple. They likely require repeated addition to perform.
A 64bit two's compliment integer has the following range.
Min Value = -2,305,843,009,213,693,952
Max Value = 2,305,843,009,213,693,951
Anything beyond that and you really should consider deflating your numbers.
Do Integer variables have an upper limit? I wanna create a custom leveling system, in which a hero unit can reach lvl 200. To reach lvl 200, the unit requires 333474250 exp (in total). Is this possible to store in an integer variable, or should I downscale the numbers?
You could have an integer for each 3 digits of the experience. Also I am not sure if the Veterancy type behaviour can hold that much experience.
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
https://www.sc2mapster.com/forums/resources/tutorials/179654-data-actor-events-message-texture-select-by-id
https://media.forgecdn.net/attachments/187/40/Screenshot2011-04-17_09_16_21.jpg
Integers are signed 32 bits (2,147,483,647 max). If you want really big numbers you can use multiple integers representing different orders of magnitude eg 1-999, 1000-999000 and 1,000,000-999,000,000 etc. and transfer between them using maths.
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
https://www.sc2mapster.com/forums/resources/tutorials/179654-data-actor-events-message-texture-select-by-id
https://media.forgecdn.net/attachments/187/40/Screenshot2011-04-17_09_16_21.jpg
The galaxy int type is a standard 32bit two's compliment integer has the following range.
Min Value = -2,147,483,648
Max Value = 2,147,483,647
Since 333,474,250 is less than 2,147,483,647 then using an int should work.
Depending on the sort of mathematical operations one needs, one can easily implement a 64bit two's compliment integer using 2 int values (a low-word and a high-word).
With addition this is fairly straight forward to do. Add the two low-word values together to produce the result of the low-word and determine if an overflow occurred. Overflow occurs with addition when {both inputs are negative} or {1 input is negative, the other input is positive and the result is not negative}. Add the two high-words together and then if overflow had occurred with the low-words add an extra 1 value to the result to produce the high-word. This is fairly simple to compute.
Subtraction is a similar idea and in worst case could be implemented using addition and negation of a number.
Multiplication and division are not so simple. They likely require repeated addition to perform.
A 64bit two's compliment integer has the following range.
Min Value = -2,305,843,009,213,693,952
Max Value = 2,305,843,009,213,693,951
Anything beyond that and you really should consider deflating your numbers.