Multiply by percentage

V

VGologist

Guest
I'm trying to make an integer value equal a percentage of itself, but I'm not getting the right value. This is the equation I have:

Total = Integer x variable/100 or in code:

Code:
Set Train_Time[TempInteger] = (TrainingTime[UnitIndex] x (TrainingIncrement[UnitIndex] / 100))
 

hio77

New Member
Reaction score
1
sorry dont have we open but im sure theres a option (being that your trying to make it used by all builds of that unit) lol i might be getting confused with buildings although :D
 

vypur85

Hibernate
Reaction score
803
I'm not too sure myself. It should be the whole line.

Should be something like that:
Code:
Set Your_Integer = (Integer(((Real(Your_Integer)) x 0.10)))

If the Your_Integer becomes fractionised, then it will be 0 as default.
 

cleeezzz

The Undead Ranger.
Reaction score
268
probably your increment, its from 0.00 - 1.00
right?

if you convert the increment to real

it would be

Code:
Set Train_Time[TempInteger] = (TrainingTime[UnitIndex] x (Integer(TrainingIncrement[UnitIndex])))

lets say train time[temp integer] = 60 x (increment, for now, lets say 25%)

so 60 x .25 = 15

like vypur said, we're not sure because we dont know the range of your variables.
or for precise time, change all of the variables to real. (unless of course you want a rounded answer)
 

Pyrogasm

There are some who would use any excuse to ban me.
Reaction score
134
The order of multiplication never matters, AceHart.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
For division though, it may.
If that increment is less than 100, the result from that integer division will be 0.
If you multiply first, it's different.
 

Pyrogasm

There are some who would use any excuse to ban me.
Reaction score
134
When working only with integers, yes... but, well, the stupid rounding conventions (1.99999 rounds to 1.0) are still dumb.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top