It just seems rather gimmicky that some reals are more precise than others. I'm pretty sure they're all either half-precision or single-precision (floats) values.
0.03125001?
Under the decimal you mean?
If you have 10 numbers under the decimal you've destroyed your precision. Even if they are 0s. A number like 0.0123456789 printed out as 0.018 or something weird like that. For 0.0123000000 it came out to a similar result, 0.018 or something weird like that.
function DistanceFromLineSegment takes real px, real py, real x1, real y1, real x2, real y2 returns real
local real r =SquareRoot((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))
local real a1=Atan2(y2-y1,x2-x1)
local real a2=Atan2(px-x1,py-y1)
if(a1>a2)then
return Sin(a1-a2)*r
endif
return Sin(a2-a1)*r
endfunction
Exactly.
What will be the next step, serious topics in the off-topic section ?!
That would be the end of the world! D:
// that would cause a syntax error, double "/" to be safe
library IsUnitDead
function IsUnitDead takes unit u returns boolean
return IsUnitType(u, UNIT_TYPE_DEAD) and GetUnitTypeId(u) != 0
endfunction
function UnitAlive takes unit u returns boolean
return not IsUnitType(u, UNIT_TYPE_DEAD) and GetUnitTypeId(u) != 0
endfunction
endlibrary
You might as well as make UnitAlive be not IsUnitDead too.JASS:function IsUnitDead takes unit u returns boolean return IsUnitType(u, UNIT_TYPE_DEAD) @and@ GetUnitTypeId(u) @!=@ 0 endfunction
library IsUnitAlive
function IsUnitAlive takes unit u returns boolean
return not IsUnitType(u, UNIT_TYPE_DEAD) and GetUnitTypeId(u) != 0
endfunction
function IsUnitDead takes unit u returns boolean
return IsUnitType(u, UNIT_TYPE_DEAD) and GetUnitTypeId(u) != 0
endfunction
function IsUnitDeadEx takes unit u returns boolean
return not IsUnitAlive(u)
endfunction
function IsUnitRemoved takes unit u returns boolean
return GetUnitTypeId(u) == 0
endfunction
endlibrary
library IsUnitAlive
function IsUnitAlive takes unit u returns boolean
return not IsUnitType(u, UNIT_TYPE_DEAD) and GetUnitTypeId(u) != 0
endfunction
function IsUnitDead takes unit u returns boolean
return not IsUnitAlive(u)
endfunction
endlibrary
function Xor takes boolean a, boolean b returns boolean
return a != b
endfunction
function Nand takes boolean a, boolean b returns boolean
return not (a and b)
endfunction
function Xnor takes boolean a, boolean b returns boolean
return a == b
endfunction
function Nor takes boolean a, boolean b returns boolean
return not (a or b)
endfunction
function Nor takes boolean a, boolean b returns boolean
return not (a or b)
endfunction
/*******************************************
*
* UnitRallyPoint
* v1.0.0.0
* By Magtheridon96
*
* - Provides GetUnitRallyPointX and GetUnitRallyPointY
*
* API:
* ----
*
* - function GetUnitRallyPointX takes unit u returns real
* - Returns the x coordinate of the rally point for a given unit
* - function GetUnitRallyPointY takes unit u returns real
* - Returns the y coordinate of the rally point for a given unit
*
*******************************************/
library UnitRallyPoint
globals
private location loc
endglobals
function GetUnitRallyPointX takes unit u returns real
local real x
set loc = GetUnitRallyPoint(u)
set x = GetLocationX(loc)
call RemoveLocation(loc)
return x
endfunction
function GetUnitRallyPointY takes unit u returns real
local real y
set loc = GetUnitRallyPoint(u)
set y = GetLocationY(loc)
call RemoveLocation(loc)
return y
endfunction
endlibrary
I spent 10 minutes trying to figure what Berb implied when he posted that :|
JASS:function Xor takes boolean a, boolean b returns boolean return a != b endfunction
function Xor takes boolean a, boolean b returns boolean
return (a or b) and (a != b)
endfunction
The one Magtheridon posted is fine, check all the cases yourself.
No, Maghtheridon's is right.
His yields the same results yours does.
This seems inline-friendly.
The compiler I spoke of also includes the optimizer. It sucks.It gets compressed again when going through optimizer.
function Xor takes boolean a, boolean b returns boolean
return a != b
endfunction
function HaiThar takes nothing returns nothing
if Xor(true, false) then
call BJDebugMsg("WOOO")
endif
endfunction
function Xor takes boolean a,boolean b returns boolean
return a != b //No, this function is not removed
endfunction
function HaiThar takes nothing returns nothing
if ((true ) != ( false)) then // INLINED!!
call BJDebugMsg("WOOO")
endif
endfunction
function HaiThar takes nothing returns nothing
if true != false then
call BJDebugMsg("WOOO")
endif
endfunction
It could be confusing. In this case it would confuse some people who don't know what Xor is, and they would have to look up the function.Having shorter code does not mean that it would be better readable or structured.
Neither would I, but that is personal preferences. I prefer making everything myself, but some people will just include shit they see being posted into their own code.If it was for the ultimate performance, I would not use any foreign code.
I already knew what Xor was and what it meant, but I was made aware of it being utterly redundant when dealing with booleans.you just learned how xor can be written for example.