Author Topic: math problem  (Read 372 times)  Share 

math problem
« on: 18 Mar 2010, 17:26 »
i have this code
[code]  index_pic = (sprite_ammount * (-currentPosition)); [/code]
but get not the result i expected.

example
index_pic = 10 * (-7);
if i type this in my calculator i get = 3
if this code is executed in AGS i get = -30

how must this statement look like, to get the result i need?

NsMn

  • HAIL CHAIRMAN MAIO, HAIL TO NINTENDISM!
    • I can help with AGS tutoring
    •  
    • I can help with backgrounds
    •  
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
Re: math problem
« Reply #1 on: 18 Mar 2010, 17:36 »
Uhmm.... I'm seriously confused. Shouldn't it be -70?

Crimson Wizard

  • AGS Project Admins
  • not et suppotreD
    • I can help with translating
    •  
Re: math problem
« Reply #2 on: 18 Mar 2010, 18:05 »
Are you sure you dont type in "10 + (-7)" on your calculator?  :)
I don't have a clue about what may be wrong with AGS , however. Because, as NsMn said, it must be -70.


Calin Leafshade

  • AGS Project Admins
  • Long live King Cat!
    • I can help with AGS tutoring
    •  
    • I can help with voice acting
    •  
  • Calin Leafshade worked on a game that was nominated for an AGS Award!Calin Leafshade worked on a game that won an AGS Award!
Re: math problem
« Reply #3 on: 18 Mar 2010, 18:13 »
i dunno if -variablename works.

you might want to try -1 * variablename

Leon: You need the sword first before you can get the monkey.

Crimson Wizard

  • AGS Project Admins
  • not et suppotreD
    • I can help with translating
    •  
Re: math problem
« Reply #4 on: 18 Mar 2010, 18:30 »
i dunno if -variablename works.
It must... I think I've used that couple of times.

CShelton

  • Program 9: Loading...
Re: math problem
« Reply #5 on: 18 Mar 2010, 18:39 »
Minus variable name does work but it gets weird with the order of operations when a multiply comes just before it.

[code]
variable1 * -variable2
[/code]

Will totally flake out, so do this instead:

[code]
-variable2 * variable1
[/code]

Oops, or just read Calin's reply that I somehow missed.

Re: math problem
« Reply #6 on: 18 Mar 2010, 18:47 »
thx, it works now.  :)