ProtoLang.net

Reference: Times

☰ Hide Sidebar
TOKEN TIMES
ALIAS *

The Times operator multiplies one numeric value by another. Mixing Data Types (e.g. Integers and Floats) is not allowed and the Times operator does not work on Strings or Booleans.

Syntax

The short syntax structure uses the * symbol:

PRINT VALUE * VALUE

The long syntax structure uses the word TIMES:

PRINT VALUE TIMES VALUE

Examples

Example: Multiplying Integer Literals

NEW INT x = 6 * 7
PRINT x // Displays "42"

Example: Multiplying Float Literals

NEW FLOAT x = 2.5 * 4.0
PRINT x // Displays "10.0"

Example: Multiplying Integer Variables

NEW INT x = 10
NEW INT y = 5
PRINT x * y // Displays "50"

Example: Scaling an Integer counter

NEW INT factor = 2
SET factor = factor * 5
PRINT factor // Displays "10"

Example: Using Times in a Loop with Integers

NEW INT i = 1
NEW INT result = 1
WHILE i <= 4
    SET result = result * i
    SET i = i + 1
END WHILE
PRINT result // Displays "24"

Common Errors

Error: Mixing Integer and Float Literals

NEW INT x = 5
NEW FLOAT y = 2.5
PRINT x * y // Type error! Cannot mix Integer and Float Data Types