# Diffrence between Rad2Deg() and bj_RADTODEG?

#### Time

##### New Member
JASS:
`` Rad2Deg() or bj_RADTODEG``

Is one faster or something? If one is faster which one would that be?

#### luorax

##### Invasion in Duskwood
I don't know what's the difference between them (I guess there isn't any) but it's definitely [ljass]bj_RADTODEG[/ljass]. 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 [ljass]Rad2Deg[/ljass], if it was faster, those speedfreaks on THW would have used it already.

#### Time

##### New Member
Ah, I see lol @ speed freaks.

#### Tyrulan

##### Ultra Cool Member
[ljass]Rad2Deg()[/ljass] is a function, and requires a lookup (through pointers) and a call stack displacement.

[ljass]bj_RADTODEG[/ljass] 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 [ljass]Rad2Deg()[/ljass] will also use [ljass]bj_RADTODEG[/ljass] to compute the returned value. What coders are really doing is skipping a step.

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

Hope this helps.

Cheers.

#### 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.).

#### Tyrulan

##### Ultra Cool Member
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.).
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.

#### 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 [ljass]DoNothing()[/ljass]

#### Tyrulan

##### Ultra Cool Member
Mhm, quite right. It's preference, since the speed difference is negligible.

#### DaFatalGigabyte

##### New Member
Thus [ljass]Rad2Deg(50)[/ljass] is actually calculating [ljass]50 * bj_RADTODEG[/ljass] ( [ljass]bj_RADTODEG[/ljass] has a value of [ljass]bj_PI / 180[/ljass]).
[ljass]bj_RADTODEG[/ljass] has a value of [ljass]180 / bj_PI[/ljass].
[ljass]bj_DEGTORAD[/ljass] has a value of [ljass]bj_PI / 180[/ljass].

#### Tyrulan

##### Ultra Cool Member
[ljass]bj_RADTODEG[/ljass] has a value of [ljass]180 / bj_PI[/ljass].
[ljass]bj_DEGTORAD[/ljass] has a value of [ljass]bj_PI / 180[/ljass].
Oops. Edited for correctness.

Thanks!

General chit-chat
Help Users
• No one is chatting at the moment.
• The Helper:
nobody signs up or comments
• The Helper:
its crazy
• The Helper:
363 bots on the forum been like that for about a month this is the most bots we have ever consistently hosted
• The Helper:
and we are on cloud flare too right?
• Stephen:
Probably stupid AI garbage. It's harvesting our Nuon knowledge.
• Stephen:
The bots I mean.
• The Helper:
I suspect AI Bots as well
• The Helper:
Happy Saturday!!!
+1
• The Helper:
I reorganized the forums somewhat but I doubt anyone would notice
• The Helper:
Happy Friday!
+1
• The Helper:
Happy Saturday!
+1
• The Helper:
The forum software says we have 554 members online now. We did not have that many unique visitors the whole day today. Too many bots and the disconnect between the forum counts and the stats.
• Varine:
Currently it says 413 guests and 2 members
+1
• Varine:
Aww
• The Helper:
That is going to be mostly bots
• The Helper:
527 (members: 2, guests: 525)
• The Helper:
Happy Saturday!
+1
• V-SNES:
Happy Saturday!
+1
• The Helper:
622 (members: 2, guests: 620)
• The Helper:
666 (members: 4, guests: 662)
+1
• Varine:
609 (members: 4, guests: 605)
• The Helper:
I was posting that last one because the 666 users online
+1
• The Helper:
Happy Wednesday Night!
+1
• The Helper:
Happy Thursday!
+1
• The Helper:
Marathon watching The Expanse!

### Members online

No members online now.

### Network Sponsors

Apex Steel Pipe - Buys and sells Steel Pipe.