Types/Int

From SC2Mapster Wiki
Jump to: navigation, search

Int[edit | edit source]

  • Int is a 32-bit integer that can have the values -2147483647 (-231 + 1) to 2147483647 (231 - 1).
  • Below are a few basic operations you can preform to integers.
int x; // Default value is 0
// -- Operations --
x = x + 10; // 10
x = x * 2; // 20
x = x / 3; // 6
x = x - 1; // 5
x = x % 2; // 1
// -- Bit Operations --
// Shift
x = x << 2; // 4
x = x >> 1; // 2
// Logic
x = x | 32; // 32 + 2 = 34
x = x & 2; // 2
x = x ^ 6; // 4
  • Note: The value -2147483648(-231) gives a numerical overflow. I wonder why this value is being reserved.