ProtoLang.net

Reference: Integer

☰ Hide Sidebar
TOKEN INTEGER
ALIAS INT

The Integer Data Type is used to represent whole numbers. Valid values (literals) are -2147483648 to 2147483647 (inclusive). Integers can be combined with Arithmetic operators to create Expressions. Arithmetic expressions containing Integers cannot contain Booleans, Floats or Strings.

Syntax

The short syntax structure uses the word INT:

NEW INT VARIABLE = VALUE

The long syntax structure uses the word INTEGER:

NEW INTEGER VARIABLE EQUAL TO VALUE

Examples

Example: Creating Integer and setting Value to Literal

NEW INT x = 5
PRINTLN x // Displays "5"

Example: Creating Integer and setting Value to Variable

NEW INT x = 5
NEW INT y = x
PRINTLN y // Displays "5"

Example: Creating Integer and setting Value to Expression using Plus operator

NEW INT x = 5
NEW INT y = x + 5
PRINTLN y // Displays "10"

Common Errors

Error: Creating Integer and setting to Boolean Literal

NEW INT x = TRUE // Runtime error! Cannot assign Boolean Literal to Integer Data Type
PRINTLN x // This line is not executed because the program crashed!

Error: Creating Integer and setting to Float Literal

NEW INT x = 1.0 // Runtime error! Cannot assign Float Literal to Integer Data Type
PRINTLN x // This line is not executed because the program crashed!

Error: Creating Integer and setting to String Literal

NEW INT x = "1" // Runtime error! Cannot assign String Literal to Integer Data Type
PRINTLN x // This line is not executed because the program crashed!