Diffrence between Rad2Deg() and bj_RADTODEG?

Discussion in 'JASS Zone' started by Time, Apr 7, 2012.

  1. Time New Member

    JASS:
     Rad2Deg() or bj_RADTODEG


    Is one faster or something? If one is faster which one would that be?
  2. luorax Invasion in Duskwood

    I don't know what's the difference between them (I guess there isn't any) but it's definitely bj_RADTODEG. It's a simple multiplication and global read, while the other native is a function call plus at least a multiplication. I've never seen anyone using Rad2Deg, if it was faster, those speedfreaks on THW would have used it already.
    1 people like this.
  3. Time New Member

    Ah, I see lol @ speed freaks.
  4. Tyrulan Active Member

    Rad2Deg() is a function, and requires a lookup (through pointers) and a call stack displacement.

    bj_RADTODEG is a constant variable. It is scoped such that access to it is much faster (and always will be) than calling a function.

    The difference then becomes in how you use them. Some people don't mind the negligible speed difference and prefer the function conversion. Some people like seeing the math. Using Rad2Deg() will also use bj_RADTODEG to compute the returned value. What coders are really doing is skipping a step.

    Thus Rad2Deg(50) is actually calculating 50 * bj_RADTODEG ( bj_RADTODEG has a value of 180 / bj_PI).

    Hope this helps.

    Cheers.
  5. Bribe vJass errors are legion

    No one I have seen has done any tests to confirm that one produces different results from the other. It's there because Blizzard wanted it to be there. One less-evil but unecessary function is I2R, especially when the GUI adds it, since it's only useful for division and could be replaced with (i + 0.).
  6. Tyrulan Active Member

    Made even further useless by the editor's limited - but still apparent - implicit casting.
    JASS:
    local integer myInteger = 1
    call DisplayTextToForce(GetPlayersAll(), R2S(I2R(myInteger)))
    call DisplayTextToForce(GetPlayersAll(), R2S(myInteger + 0.))
    call DisplayTextToForce(GetPlayersAll(), R2S(myInteger))

    The last 2 of the 3 displays use implicit casting. All are syntactically correct and produce the same results.
    BlackRose and Bribe like this.
  7. GFreak45 I didnt slap you, i high 5'd your face.

    the way you are talking about this is like blizzard never makes useless functions, yet bjs still exist, the gui ifs add nots to every conditional statement, and plenty of gui functions cause crashes in the editor, blizzard are game-makers, not language designers or even game completors (every game they release is unfinished)

    but yes, to answer the question, whenever you have an option between using a variable and simple math it will always be faster than any function call, even DoNothing() :p
  8. Tyrulan Active Member

    Mhm, quite right. It's preference, since the speed difference is negligible.
  9. DaFatalGigabyte New Member

  10. Tyrulan Active Member

Share This Page