UE2:Object operators (UT2004)

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to navigation Jump to search
UT2004 Object (operators)

Contents

Operators below are grouped by type and sorted by precedence.

Apart from the operators listed here, there are also a few implicitly declared operators, like assignment and generic struct (in)equality.

Bool operators

!bool

native(129) static final preoperator bool ! (bool A)

Logical negation. Returns False if the parameter is True and vice versa.

bool == bool

native(242) static final operator(24) bool == (bool A, bool B)

Equality. Returns True if both parameters have the same value, otherwise False.

bool != bool

native(243) static final operator(26) bool != (bool A, bool B)

Inequality. Returns True if the parameters have different values, otherwise False

bool && bool

native(130) static final operator(30) bool && (bool A, skip bool B)

Logical AND. Returns True if both parameters are True, otherwise False.

This operator "short-circuits" if the first operand evaluates to False, i.e. in that case the second operand is not evaluated at all because the result is already known.

bool ^^ bool

native(131) static final operator(30) bool ^^ (bool A, bool B)

Logical XOR. This is basically the same as the != operator, except that the inequality operator binds more tightly than XOR.

bool || bool

native(132) static final operator(32) bool || (bool A, skip bool B)

Logical OR. Returns True if any parameter is True, and False only if both parameters are False.

This operator "short-circuits" if the first operand evaluates to True, i.e. in that case the second operand is not evaluated at all because the result is already known.

Byte operators

++byte

native(137) static final preoperator byte ++ (out byte A)

Preincrement operator. The value of A is incremented by one and the result is returned.

--byte

native(138) static final preoperator byte -- (out byte A)

Predecrement operator. The value of A is decremented by one and the result is returned.

byte++

native(139) static final postoperator byte ++ (out byte A)

Postincrement operator. The value of A is temporarily stored, then A is incremented by one and the original value is returned.

byte--

native(140) static final postoperator byte -- (out byte A)

Postdecrement operator. The value of A is temporarily stored, then A is decremented by one and the original value is returned.

byte *= byte

native(133) static final operator(34) byte *= (out byte A, byte B)

Combined multiplication and assign. Multiplies A with B, stores the result in A and returns it. Note that float values are automatically typecasted to byte for this operator: <uscript> local byte b; b = 4; b *= 2.5; // afterwards b is 8, not 10 </uscript>

byte += byte

native(135) static final operator(34) byte += (out byte A, byte B)

Combined add and assign. Adds A and B, stores the result in A and returns it.

byte -= byte

native(136) static final operator(34) byte -= (out byte A, byte B)

Combined subtract and assign. Subtracts B from A, stores the result in A and returns it.

byte /= byte

native(134) static final operator(34) byte /= (out byte A, byte B)

Combined divide and assign. Divides A by B, stores the result in A and returns it. Note that float values are automatically typecasted to byte for this operator: <uscript> local byte b; b = 10; b /= 2.5; // afterwards b is 5, not 4 </uscript> If you need a floating point operation, use A *= 1.0 / B; instead.

Int operators

++int

native(163) static final preoperator int ++ (out int A)

Preincrement operator. The value of A is incremented by one and the result is returned.

-int

native(143) static final preoperator int - (int A)

Arithmetic negation. The result is a number with the same magnitude, but opposite sign. For zero A the result obviously is 0. Note that this operator maps the smallest possible int number (-2147483648 or 0x80000000) onto itself because its positive counterpart is larger than the largest possible int number.

--int

native(164) static final preoperator int -- (out int A)

Predecrement operator. The value of A is decremented by one and the result is returned.

~int

native(141) static final preoperator int ~ (int A)

Bitwise NOT, or complement operator. Inverts all bits in the binary representation of A and returns that value.

int++

native(165) static final postoperator int ++ (out int A)

Postincrement operator. The value of A is temporarily stored, then A is incremented by one and the original value is returned.

int--

native(166) static final postoperator int -- (out int A)

Postdecrement operator. The value of A is temporarily stored, then A is decremented by one and the original value is returned.

int * int

native(144) static final operator(16) int * (int A, int B)

Integer multiplication. Multiplies A and B and returns the result.

int / int

native(145) static final operator(16) int / (int A, int B)

Integer division. Divides A by B and returns the result. Any remainder after division is lost. Division by 0 is defined to return 0.

int + int

native(146) static final operator(20) int + (int A, int B)

Integer addition. Adds A and B and returns the result.

int - int

native(147) static final operator(20) int - (int A, int B)

Integer subtraction. Subtracts B from A and returns the result.

int << int

native(148) static final operator(22) int << (int A, int B)

Arithmetic or logical left shift. Moves the bits in the binary representation of A to the left. Higher bits are "pushed out" to the left and from the right, zero bits are "pushed in". Arithmetic left shift corresponds to integer multiplication with 2B.

B is the distance to shift the bits. If it is negative or greater than 31, B is implicitly normalized to the range 0 to 31 as if by B & 0x1F.

int >> int

native(149) static final operator(22) int >> (int A, int B)

Arithmetic right shift. Moves the bits in the binary representation of A to the right. Lower bits are "pushed out" to the right and depending on the sign of the value, either 0 (for positive numbers) or 1 (for negative numbers) bits are "pushed in" from the left. Arithmetic right shift corresponds to integer division by 2B.

B is the distance to shift the bits. If it is negative or greater than 31, B is implicitly normalized to the range 0 to 31 as if by B & 0x1F.

int >>> int

native(196) static final operator(22) int >>> (int A, int B)

Logical right shift. Moves the bits in the binary representation of A to the right. Higher bits are "pushed out" to the left and from the right, zero bits are "pushed in".

B is the distance to shift the bits. If it is negative or greater than 31, B is implicitly normalized to the range 0 to 31 as if by B & 0x1F.

int < int

native(150) static final operator(24) bool < (int A, int B)

Less-than comparison operator. Returns True if the value of A is less than the value of B.

int <= int

native(152) static final operator(24) bool <= (int A, int B)

Less-or-equal comparison operator. Returns True if the value of A is less than or equal to the value of B.

int == int

native(154) static final operator(24) bool == (int A, int B)

Equality operator. Returns True if the value of A is equal to the value of B.

int > int

native(151) static final operator(24) bool > (int A, int B)

Greater-than comparison operator. Returns True if the value of A is greater than the value of B.

int >= int

native(153) static final operator(24) bool >= (int A, int B)

Greater-or-equal comparison operator. Returns True if the value of A is greater than or equal to the value of B.

int != int

native(155) static final operator(26) bool != (int A, int B)

Inequality operator. Returns True if the value of A differs from the value of B.

int & int

native(156) static final operator(28) int & (int A, int B)

Bitwise AND operator. Performs logical AND on each corresponding pair of bits from A and B and returns the result. Unlike the bool && bool operator, the bitwise AND operator always evaluates both operands.

int ^ int

native(157) static final operator(28) int ^ (int A, int B)

Bitwise XOR operator. Performs logical XOR on each corresponding pair of bits from A and B and returns the result.

int | int

native(158) static final operator(28) int | (int A, int B)

Bitwise OR operator. Performs logical OR on each corresponding pair of bits from A and B and returns the result. Unlike the logical OR operator, the bitwise OR operator always evaluates both operands.

int *= float

native(159) static final operator(34) int *= (out int A, float B)

Combined multiply and assign. Multiplies A and B, stores the result in A and returns it.

Note: This operator always performs floating point multiplication and thus may be inaccurate for large values. If you need precision for large values, use A = A * B instead.

int += int

native(161) static final operator(34) int += (out int A, int B)

Combined add and assign. Adds A and B, stores the result in A and returns it.

int -= int

native(162) static final operator(34) int -= (out int A, int B)

Combined subtract and assign. Subtracts B from A, stores the result in A and returns it.

int /= float

native(160) static final operator(34) int /= (out int A, float B)

Combined divide and assign. Divides A by B, stores the result in A and returns it.

Note: This operator always performs floating point division and thus may be inaccurate for large values. If you need precision for large values, use A = A / B instead.

Float operators

Some floating point operators have the potential of overflowing the valid range of float values. If this happens, they return a "float error value". Such a value also propagates through operators and function calls if it is passed as a parameter.

-float

native(169) static final preoperator float - (float A)

Arithmetic negation. The result is a number with the same magnitude, but opposite sign. For zero A the result obviously is 0.

float ** float

native(170) static final operator(12) float ** (float A, float B)

Exponentiation operator. Raises A to the power of B and returns the result. Attempting to raise a negative number to a fractional power results in NaN.

float * float

native(171) static final operator(16) float * (float A, float B)

Floating point multiplication. Multiplies A and B and returns the result.

float / float

native(172) static final operator(16) float / (float A, float B)

Floating point division. Divides A by B and returns the result. Division by zero results in NaN.

float % float

native(173) static final operator(18) float % (float A, float B)

Remainder after (truncated) division, also called the modulo operator. Divides A by B and returns the remainder. Division by zero results in NaN. For negative values of A, the result is negative as well.

float + float

native(174) static final operator(20) float + (float A, float B)

Floating point addition. Adds A and B and returns the result.

float - float

native(175) static final operator(20) float - (float A, float B)

Floating point subtraction. Subtracts B from A and returns the result.

float < float

native(176) static final operator(24) bool < (float A, float B)

Less-than comparison operator. Returns True if the value of A is less than the value of B.

float <= float

native(178) static final operator(24) bool <= (float A, float B)

Less-or-equal comparison operator. Returns True if the value of A is less than or equal to the value of B.

float == float

native(180) static final operator(24) bool == (float A, float B)

Equality comparison operator. Returns True if the value of A is equal to the value of B.

float > float

native(177) static final operator(24) bool > (float A, float B)

Greater-than comparison operator. Returns True if the value of A is greater than to the value of B.

float >= float

native(179) static final operator(24) bool >= (float A, float B)

Greater-or-equal comparison operator. Returns True if the value of A is greater than or equal to the value of B.

float ~= float

native(210) static final operator(24) bool ~= (float A, float B)

Approximately-equal comparison operator. Returns True if the values of A and B differ by less than 0.0001.

float != float

native(181) static final operator(26) bool != (float A, float B)

Inequality comparison operator. Returns True if the value of A is different from the value of B.

float *= float

native(182) static final operator(34) float *= (out float A, float B)

Combined multiply and assign. Multiplies A and B, stores the result in A and returns it.

float += float

native(184) static final operator(34) float += (out float A, float B)

Combined add and assign. Adds A and B, stores the result in A and returns it.

float -= float

native(185) static final operator(34) float -= (out float A, float B)

Combined subtract and assign. Subtracts B from A, stores the result in A and returns it.

float /= float

native(183) static final operator(34) float /= (out float A, float B)

Combined divide and assign. Divides A by B, stores the result in A and returns it.

Vector operators

-vector

native(211) static final preoperator Vector - (Vector A)

Inverts the vector by negating its components. The resulting vector has the same length, but points in the opposite direction.

float * vector

native(213) static final operator(16) Vector * (float A, Vector B)

Multiplies the vector's components by a scalar value. The resulting vector's length it the original vector's length multiplied by the absolute value of the scalar. Its direction is the same if the scalar is positive and inversed if the scalar is negative.

vector * float

native(212) static final operator(16) Vector * (Vector A, float B)

Same as float * vector, just with swapped operands.

vector * vector

native(296) static final operator(16) Vector * (Vector A, Vector B)

Multiplies the corresponding components of the two vectors and returns them as the corresponding commponents of the resulting vector.

vector / float

native(214) static final operator(16) Vector / (Vector A, float B)

Divides the vector's components by a scalar value. The resulting vector's length it the original vector's length divided by the absolute value of the scalar. Its direction is the same if the scalar is positive and inversed if the scalar is negative.

vector Cross vector

native(220) static final operator(16) Vector Cross (Vector A, Vector B)

Calculates the cross product of the two vectors. The result is a vector perpenticular to both input vectors. Its length is equal to the area of the parallelogram described by the two vectors.

vector Dot vector

native(219) static final operator(16) float Dot (Vector A, Vector B)

Calculates the dot product of the two vectors. The result is a scalar value, the sum of the products of corresponding components of the two vectors.

vector + vector

native(215) static final operator(20) Vector + (Vector A, Vector B)

Adds the two vectors' corresponding components. The resulting vector can be constructed geometrically by attaching the initial point of vector B to the endpoint of vector A. Now the vector starting at the initial point of A and ending at the endpoint of B has the same length and orientation as the resulting vector.

vector - vector

native(216) static final operator(20) Vector - (Vector A, Vector B)

Subtracts the components of vector B from the corresponding components of vector A. The resulting vector can be constructed geometrically by attaching the endpoint of vector B to the endpoint of vector A. Now the vector starting at the initial point of A and ending at the initial point of vector B has the same length and orientation as the resulting vector.

vector << rotator

native(275) static final operator(22) Vector << (Vector A, Rotator B)

Vector local-to-global transformation. Imagine a "view offset" vector, e.g. for the weapon in 1st-person view. Such a vector value describes an offset for when the camera points in positive world X-axis direction, with the camera's "up" direction being the same as the world's "up" direction. Now imagine the camera is oriented a different way and the view offset vector needs to be transformed to world coordinates. This is exactly what OffsetVector << CameraRotation does.

Often the GetAxes() function is used for the same transformation: <uscript> local vector CamX, CamY, CamZ, Result;

GetAxes(CameraRotation, CamX, CamY, CamZ); Result = OffsetVector.X * CamX + OffsetVector.Y * CamY + OffsetVector.Z * CamZ; </uscript>

vector >> rotator

native(276) static final operator(22) Vector >> (Vector A, Rotator B)

Vector global-to-local transformation. This operation is the reverse of the vector << rotator operator, as it could be used to transform an offset vector from world coordinates to local camera coordinates. The code example would be largely the same, except that GetUnAxes() would be used,

vector == vector

native(217) static final operator(24) bool == (Vector A, Vector B)

Vector equality operator. Returns True if both vectors have the same length and orientation, which can only be true if their corresponding components are equal.

vector != vector

native(218) static final operator(26) bool != (Vector A, Vector B)

Vector inequality operator. Returns True if the two vectors differ in length or orientation, which happens if any of the corresponding components are different.

vector *= float

native(221) static final operator(34) Vector *= (out Vector A, float B)

Combined scalar multiply and assign. Multiplies vector A by scalar value B, stores the result in A and returns it.

vector *= vector

native(297) static final operator(34) Vector *= (out Vector A, Vector B)

Combined vector component multiply and assign. Multiplies the corresponding components of A and B, stores the resulting vector in A and returns is.

vector += vector

native(223) static final operator(34) Vector += (out Vector A, Vector B)

Combined vector add and assign. Adds A and B, stores the resulting vector in A and returns it.

vector -= vector

native(224) static final operator(34) Vector -= (out Vector A, Vector B)

Combined vector subtract and assign. Subtracts B from A, stores the resulting vector in A and returns it.

vector /= float

native(222) static final operator(34) Vector /= (out Vector A, float B)

Combined scalar divide and assign. Divides vector A by scalar B, stores the result in A and returns it.

Rotator operators

float * rotator

native(288) static final operator(16) Rotator * (float A, Rotator B)

Multiplies each component of the rotator with the float value and returns the resulting rotator. This operator probably makes more sense for rotation rates than for object orientations. Note that rotator components are of type int, so the results will have their fractional part truncated.

rotator * float

native(287) static final operator(16) Rotator * (Rotator A, float B)

Same as float * rotator, just with the operands swapped.

rotator / float

native(289) static final operator(16) Rotator / (Rotator A, float B)

Divides each component of the rotator by the float value and returns the resulting rotator. This operator probably makes more sense for rotation rates than for object orientations. Note that rotator components are of type int, so the results will have their fractional part truncated.

rotator + rotator

native(316) static final operator(20) Rotator + (Rotator A, Rotator B)

Adds the corresponding components of the rotators and returns the resulting rotator.

rotator - rotator

native(317) static final operator(20) Rotator - (Rotator A, Rotator B)

Subtracts the component values of B from the corresponding components of A and returns the resulting rotator.

rotator == rotator

native(142) static final operator(24) bool == (Rotator A, Rotator B)

Rotator equality. Returns True if the corresponding components of the two rotators have identical values. To compare rotators for orientation, if may be necessary to Normalize() their components first. Sometimes that doesn't work either: for example rot(0,32768,0) != rot(32768,0,32768) even though these two rotator literals actually have the same effect if used e.g. as camera rotation.

int ClockwiseFrom int

native static final operator(24) bool ClockwiseFrom (int A, int B)

Compares corresponding normalized component values of two rotators and returns True if the shortest rotation direction from A to B would be in clockwise direction, i.e. by incrementing A until it reaches B.

Yes, this is actually an int operator returning a bool result. It is listed here among the rotator operators nonetheless because its use it closely related to rotators.

rotator != rotator

native(203) static final operator(26) bool != (Rotator A, Rotator B)

Rotator inequality. Returns True if any corresponding components of the two rotators differ. As mentioned for the == operator above, this doesn't necessarily mean that the rotators represent different orientations.

rotator *= float

native(290) static final operator(34) Rotator *= (out Rotator A, float B)

Combined rotator multiply and assign. Multiplies each component of rotator A by B, stores the result in A and returns it.

rotator += rotator

native(318) static final operator(34) Rotator += (out Rotator A, Rotator B)

Combined rotator add and assign. Adds the corresponding components of rotators A and B, stores the result in A and returns it.

rotator -= rotator

native(319) static final operator(34) Rotator -= (out Rotator A, Rotator B)

Combined rotator subtract and assign. Subtracts the components of rotator B from the corresponding components of A, stores the result in A and returns it.

rotator /= float

native(291) static final operator(34) Rotator /= (out Rotator A, float B)

Combined rotator divide and assign. Divides each component of rotator A by B, stores the result in A and returns it.

String operators

string < string

native(115) static final operator(24) bool < (string A, string B)

Compares the strings case-sensitively and returns True if A comes before B in lexicographical order.

string <= string

native(120) static final operator(24) bool <= (string A, string B)

Compares the strings case-sensitively and returns True if A is identical to B or comes before B in lexicographical order.

string == string

native(122) static final operator(24) bool == (string A, string B)

Case-sensitive string equality. Returns True if A and B contain the exact same characters in exactly the same order.

string > string

native(116) static final operator(24) bool > (string A, string B)

Compares the strings case-sensitively and returns True if A comes after B in lexicographical order.

string >= string

native(121) static final operator(24) bool >= (string A, string B)

Compares the strings case-sensitively and returns True if A is identical to B or comes after B in lexicographical order.

string ~= string

native(124) static final operator(24) bool ~= (string A, string B)

Case-insensitive string equality. Returns True if the two strings are either equal or only differ by case.

string != string

native(123) static final operator(26) bool != (string A, string B)

Case-sensitive string inequality. Returns True if the strings do not contain the exact same characters in exactly the same order. This includes different case.

To compare two strings for case-insensitive inequality you can either compare their capitalized versions for inequality (Caps(A) != Caps(B)) or negate the result of the case-insensitive equality operator (!(A ~= B)).

string $ string

native(112) static final operator(40) string $ (coerce string A, coerce string B)

String concatenation. Returns a string that contains the content of B appended to the content of A: "Hello" $ "World" results in the string "HelloWorld".

string @ string

native(168) static final operator(40) string @ (coerce string A, coerce string B)

Spaced string concatenation. Same as string $ string, but the two strings are separated by a space character in the result: "Hello" @ "World" results in the string "Hello World".

string $= string

native(322) static final operator(44) string $= (out string A, coerce string B)

Combined concate and assign. Appends the content of B to A, stores the result in A and returns it.

string @= string

native(323) static final operator(44) string @= (out string A, coerce string B)

Combined spaced concate and assign. Appends a space character and the content of B to A, stores the result in A and returns it.

string -= string

native(324) static final operator(45) string -= (out string A, coerce string B)

Combined string removal and assign. Finds all occurrences of B in A and removes them. The result is stored in A and returned. Occurences of B that are a result of a removal operation are ignored: "aaabbb" -= "ab" results in "aabb".

Name operators

name == name

native(254) static final operator(24) bool == (name A, name B)

Name equality. Returns True if A and B represent the same name value.

name != name

native(255) static final operator(26) bool != (name A, name B)

Name inequality. Returns True if A and B represent different name value.

Object operators

Object == Object

native(114) static final operator(24) bool == (Object A, Object B)

Object equality. Returns True if A and B either point to the same object or are both None.

Object != Object

native(119) static final operator(26) bool != (Object A, Object B)

Object inequality. Returns True if A and B point to different objects or one is None while the other isn't.