# [Trigger]Strange Income numbers

Status
Not open for further replies.

#### Delerith

Level 3
Hello, I've been making a map for a week or so and this is the income trigger I have been using:
• Income
• Events
• Time - Every 60.00 seconds of game time
• Conditions
• Actions
• Set Income = ((Income x 115) / 100)
• Player Group - Pick every player in (All players) and do (Player - Add Income to (Picked player) Current gold)
• Game - Display to (All players) the text: (You get + ((|cffffcc00 + ((String(Income)) + |r)) + gold from income.))
It works fine and after circa 90 incomes the amounts looked like this:
Income 92: 15527250
Income 93:17856337
Income 94: 20534787
Income 95: -19334667
Income 96: 20952878
Income 97:-18853863
Income 98: 21267730
Income 99: -18491783
Income 100: -21265550
Income 101: 18494290
Income 102: 21268433
Income 103: -18490975
Income 104: -21264621
Income 105: 18495358

The increment of the income is 15% so why does it become negative?

Anyway, I've changed it now because the amounts aren't supposed to go so ridiculously high.

Last edited:

#### Xelephant

Level 6
i think it is because cant calculate big number very well. why dont you do it like this:

• Income
• Events
• Time - Every 60.00 seconds of game time
• Conditions
• Actions
• Set Increase = 1.15
• Set Income = (Income x Increase)
• Player Group - Pick every player in (All players) and do (Player - Add Income to (Picked player) Current gold)
• Game - Display to (All players) the text: (You get + ((|cffffcc00 + ((String(Income)) + |r)) + gold from income.))
Increase should be a real value

#### Delerith

Level 3
The Income is an integer value and the increase a real. Integer values can't be multiplied with real values. Atleast not in this scenario. I've changed the income to real but I always get lots of extra numbers i.e. 133.506. How can I approximate (is that how you say it? My English vocabulary isn't that good.) this number to a whole number?

#### Need_O2

Level 19
Convert integer to string
-------Convert Real to integer

#### Delerith

Level 3
It was really hard to understand your post Need_O2 but I managed to fix it with your help.

Thank you.

#### Dr Super Good

Spell Reviewer
Level 64
The reason the error occured in the firstplace was you exceeded the maximum size of a 32 bit variable by multiplying by 115 before dividing and thus it errored and changed the sign bit and then preformed the division.

One way to work around this would be to use a form of scientific notation (ofcourse losing accuracy after a certian number). For this you basically have a real as your number and then multiply that by 10 and use and integer for the power of that 10. However you already solved it and thus this method is pointless unless you want to work with insainly high numbers.

Status
Not open for further replies.

Replies
14
Views
1K
Replies
3
Views
623
Replies
4
Views
765
Replies
5
Views
529
Replies
4
Views
1K