• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Evaluated] [Assignment] Week 1

Status
Not open for further replies.

ABM

ABM

Level 7
Joined
Jul 13, 2005
Messages
279
well, the order is left to right, but it is just a logical guess because actually:
doing : a/b*c/d*e-f
if you do ((((a/b)*c)/d)*e)-f the result will be same as:
if you do (a/b)*(c/d)*e-f
actually i will check if a+b/c-d*e/f
normally / and * should come before + and -
so it should go (a+(b/c)-(d*e))/f
unless you do in math (((a+b)/(c-d))*e)/f
but i wonder if Jass access () to make math priority ?

[Jass=]
//! runtextmacro variables()
// This is where you should delcare your variables
// Remember, (type) (name)

// Assignment sector:
integer a
integer b
integer c
integer d
integer e
integer f
real g
real h
real ab
real cd
//! runtextmacro endvariables()

//! runtextmacro actions()
// This is where you should put all the code that modifies
// and plays with the variables you declared above.
set a = 6
set b = 5
set c = 4
set d = 3
set e = 2
set f = 1
set ab = 6./5
set cd = 4./3
set g = a/b*c/d*e-f
set h = ab*cd*e-f

// Assignment sector:
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, "total is " + I2S(R2I(a/b*c/d*e-f)))
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, "total is " + R2S(g))
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, R2S(ab)+"X "+ R2S(cd)+"X 2 - 1 = "+ R2S(h))

//! runtextmacro endactions()[/code]

one result show 1.00 but it is just a bug because integer divide into integer only, the other result using real is correct result.
second test using a+b/c-d*e/f
[Jass=]//! runtextmacro variables()
// This is where you should delcare your variables
// Remember, (type) (name)

// Assignment sector:
real a
real b
real c
real d
real e
real f
real g
real h
real ab
real cd
//! runtextmacro endvariables()

//! runtextmacro actions()
// This is where you should put all the code that modifies
// and plays with the variables you declared above.
set a = 6.
set b = 5.
set c = 4.
set d = 3.
set e = 2.
set f = 1.
set ab = 6.+5
set cd = 4.-3
set g = a+b/c-d*e/f
set h = ab/cd*e-f

// Assignment sector:
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, "total is " + R2S(a+b/c-d*e/f))
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, "total is " + R2S(g))
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, R2S(ab)+"X "+ R2S(cd)+"X 2 - 1 = "+ R2S(h))

//! runtextmacro endactions()[/code]

result is 1.25 and 22
wich mean Jass make operation in order from left to right
 
Status
Not open for further replies.
Top