ProtoLang.net

Reference: Divided By

☰ Hide Sidebar
TOKEN DIVIDED BY
ALIAS /

The Divided By operator divides one numeric value by another. Mixing Data Types (e.g. Integers and Floats) is not allowed and the Divided By 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 words DIVIDED BY:

PRINT VALUE DIVIDED BY VALUE

Examples

Example: Dividing Integer Literals

NEW INT x = 20 / 5
PRINT x // Displays "4"

Example: Dividing Float Literals

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

Example: Dividing Integer Variables

NEW INT x = 100
NEW INT y = 10
PRINT x / y // Displays "10"

Example: Halving an Integer value

NEW INT amount = 50
SET amount = amount / 2
PRINT amount // Displays "25"

Example: Using Divided By in a Loop with Integers

NEW INT i = 100
WHILE i >= 10
    SET i = i / 2
END WHILE
PRINT i // Displays "6"

Common Errors

Error: Mixing Integer and Float Literals

NEW INT x = 10
NEW FLOAT y = 2.0
PRINT x / y // Type error! Cannot mix Integer and Float Data Types