The Daily Click ::. Forums ::. Klik Coding Help ::. Question about some simple math stuff
 

Post Reply  Post Oekaki 
 

Posted By Message

siven

I EAT ROCKS

Registered
  03/11/2008
Points
  604

Wii OwnerVIP Member
18th December, 2014 at 18/12/2014 02:08:27 -

This...
(Current Attack( "Player Bot Stats" )+Attack 3 Damage( "Player Bot Stats" )+Additional Damage( "Player Bot Stats" ))*2-Current Defense( "Enemy bots alterable stats" )

is not the same (and will give different outcome) than this.... right?
Current Attack( "Player Bot Stats" )+Attack 3 Damage( "Player Bot Stats" )+Additional Damage( "Player Bot Stats" )*2-Current Defense( "Enemy bots alterable stats" )

the brackets makes it do the math inside the brackets before doing the math outside of the brackets, right? so then, if i really wanted to specify the order in which to add and subtract id have to use brackets right? or am i totally wrong in every way possible.

 
[Game design makes my brain feel like its gonna explode.]

GamesterXIII



Registered
  04/12/2008
Points
  1110

I am an April Fool
27th December, 2014 at 27/12/2014 02:53:55 -

You are correct. You can manually plug in the numbers to see how they act.

Coding will always handle things in the correct Order of Operations which is:

Parentheses, exponents, multiplication OR division, addition OR subtraction.




Lets assign your "Variables" values.

Current Attack = A = 2
Attack 3 Damage = B = 5
Additional Damage = C = 10
Current Defense = D = 7

your first formula would become:

(A + B + C) * 2 - D
OR
(2 + 5 + 10) * 2 - 7

(17)*2-7
34-7
27

your second formula would become:

A+B+C*2-D
OR
2+5+10*2-7

Considering order of operations, the code will handle the multiplication first - which causes your formula to look like this.

2+5+20-7
10+20-7
30-7
23

Edited by GamesterXIII

 
n/a

siven

I EAT ROCKS

Registered
  03/11/2008
Points
  604

Wii OwnerVIP Member
5th January, 2015 at 05/01/2015 23:03:13 -

That explains all of my issues with my latest project! thanks a ton. i wasnt sure how mmf2 handled it, or if i was even right lol. its been quite a while since ive been in a math class. guess im a tad rusty haha

 
[Game design makes my brain feel like its gonna explode.]
   

Post Reply



 



Advertisement

Worth A Click