Jump to content

Mscr:System.Types.Int32

From Ironworks Games Wiki
Revision as of 11:49, 24 August 2026 by Nlondon (talk | contribs) (→Details)

A 32-bit integral numeric.

Capable of storing values between -2,147,483,648 and 2,147,483,647.

Details

struct System.Types.Int32 : Object
Aliased as: int
Object Type: struct (Copy by Value)
Inherits From: System.Types.Object

Unary Operators

operator- (Negate)

Int32 operator -(Int32 a)

Returns the negative value of the operand.

operator+ (Positive)

Int32 operator +(Int32 a)

Returns the same value as the operand. Mostly used for alignment with the '-' operator.

operator-- (Decrement)

Int32 operator --(Int32 a)

Decrements the value contained in the operand. If used as a prefix, will return the decremented value. If used as a postfix, will return the original value before decrementing.

operator++ (Increment)

Int32 operator ++(Int32 a)

Increments the value contained in the operand. If used as a prefix, will return the incremented value. If used as a postfix, will return the original value before incrementing.

operator! (Logical NOT)

Int32 operator !(Int32 a)

Logical NOT operation. Will return `false` if the operand is zero, and `true` if the operand is non-zero.

operator~ (Bitwise NOT)

Int32 operator ~(Int32 a)

Bitwise NOT operation. Will return the inverted bits of the supplied operand.

00100101b would become 11011010b

Binary Operators

operator+ (Add)

Int32 operator +(Int32 a, Int32 b)

Adds the value of both operands and returns the result.

operator- (Subtract)

Int32 operator -(Int32 a, Int32 b)

Subtracts operand `b` from operand `a` and returns the result.

operator* (Multiply)

Int32 operator *(Int32 a, Int32 b)

Multiplies operand `a` by operand `b` and returns the result.

operator/ (Divide)

Int32 operator /(Int32 a, Int32 b)

Divides operand `a` by operand `b` and returns the result.

warning: Dividing an Int32 by 0 will throw an exception.

operator% (Modulo)

Int32 operator %(Int32 a, Int32 b)

Performs a modulo operation on operand `a`, dividing it by operand `b` and returning the remainder.

warning: Dividing an Int32 by 0 will throw an exception.

operator<< (Shift Left)

Int32 operator <<(Int32 a, Int32 b)

Shifts the value of operand `a` left by `b` bits

operator>> (Shift Right)

Int32 operator >>(Int32 a, Int32 b)

Shifts the value of operand `a` right by `b` bits

operator& (Bitwise AND)

Int32 operator &(Int32 a, Int32 b)

Performs a bitwise AND operation between operand `a` and `b`, where the resulting value will only have bits set if the corresponding bits in both operands are 1.

Example: {{{text}}}

operator| (Bitwise OR)

Int32 operator |(Int32 a, Int32 b)

Performs a bitwise OR operation between operand `a` and `b`, where the resulting value will have bits set if either of the corresponding bits in both operands are 1.

Example: 01010101b

operator^ (Bitwise Xor)

Int32 operator ^(Int32 a, Int32 b)

Performs a bitwise OR operation between operand `a` and `b`, where the resulting value will have bits set if either of the corresponding bits in both operands are 1.

Example: 01010101b

operator== (Equal)

bool operator ==(Int32 a, Int32 b)

Returns true if operand `a` is exactly equal to operand `b`.

operator!= (Not Equal)

bool operator !=(Int32 a, Int32 b)

Returns true if operand `a` is NOT equal to operand `b`.

operator< (Less than)

bool operator <(Int32 a, Int32 b)

Returns true if operand `a` is less than operand `b`.

operator<= (Less than or Equal)

bool operator <=(Int32 a, Int32 b)

Returns true if operand `a` is less than or equal to operand `b`.

operator> (Greater than)

bool operator >(Int32 a, Int32 b)

Returns true if operand `a` is greater than operand `b`.

operator>= (Greater than or Equal)

bool operator >=(Int32 a, Int32 b)

Returns true if operand `a` is greater than or equal to operand `b`.

Casting

Implicit casts

Implicit casts happen automatically, except in the case that a method argument is marked as explicit. Lower cost casts have a higher automatic precedence in the case of method overload resolution.

Type Additional Info Cost
System.Types.Bool (bool) Casts to false if zero, true if nonzero 10
System.Types.Int64 (int64) Casts to a 64-bit integer, padding the top 32 bits with zero 1
System.Types.Float (float) Casts to 32-bit floating point number.

Some precision loss may occur with high numbers.

1
System.Types.Double (double) Casts to 64-bit floating point number.

Some precision loss may occur with high numbers.

2

Explicit casts

Explicit casts will NOT happen automatically, and must use either C-style casts ((int)Value) or C#-style casts (Value as int).

Type Additional Info
System.Types.Char (char) Casts to the corresponding character in the general ASCII set
System.Types.Int8 (int8) Casts to an 8-bit integer, discarding the top 24 bits
System.Types.Int16 (int16) Casts to an 16-bit integer, discarding the top 16 bits
System.Types.UInt8 (uint8) Casts to an unsigned 8-bit integer, discarding the top 24 bits.
System.Types.UInt16 (uint16) Casts to an unsigned 16-bit integer, discarding the top 16 bits.
System.Types.UInt16 (uint32) Casts to an unsigned 32-bit integer.

Negative values will end up as large positives.

System.Types.UInt16 (uint64) Casts to an unsigned 64-bit integer, padding the top 32 bits with zero.

Negative values will end up as large positives.