ScripticXLearn programming visually
Platform
Problems
Community
Leaderboard
Learn
Docs
MiniScript+ basicsVariablesOperators and expressionsInput and outputConditions and decisionsLoopsStringsSums, counts, and extremaDigits of a numberDivisibility and prime numbersNumeric sequences and recurrencesNumber basesFunctions and parametersRecursion
Examples
Basic programsConditionsInput and outputLoopsAlgorithmsWorking with textDigit problemsBase conversionsFunctions and recursionEncode text with a key
What's newHelpContact
Loading…

Documentation

MiniScript+

DocumentationMiniScript+
Getting started
MiniScript+ basics
Language basics
VariablesOperators and expressionsInput and outputConditions and decisionsLoopsStrings
Elementary algorithms
Sums, counts, and extremaDigits of a numberDivisibility and prime numbersNumeric sequences and recurrencesNumber bases
Functions
Functions and parametersRecursion
Documentation/Operators and expressions

Operators and expressions

Build calculations and conditions; understand division and evaluation order.

On this page
ArithmeticEvaluation orderComparisons and logicNumeric functionsPractice

An expression combines values, variables, operators, and function calls to produce one value. In price * quantity, * is the operator and the two names are its operands. An assignment such as total = price * quantity stores that result.

Arithmetic#

OperatorMeaningExampleResult
+Addition7 + 411
-Subtraction7 - 43
*Multiplication7 * 428
/Division7 / 41.75
DIVInteger quotient, truncated toward zero7 DIV 41
MOD or %Remainder7 MOD 43

For non-negative integers and a positive divisor, a = (a DIV b) * b + a MOD b. A zero divisor raises an error. With negatives, -7 DIV 4 is -1 and -7 MOD 4 is -3; the remainder is not always positive.

MS+MiniScript+
1PRINT 23 DIV 52PRINT 23 MOD 53PRINT 23 / 5

The output is 4, 3, 4.6: twenty-three objects make four complete groups of five, with three left over.

Evaluation order#

Parentheses come first. Next come unary operators (-, NOT), then *, /, DIV, MOD, then +, -, comparisons, AND, and finally OR. Binary operators at the same level associate from left to right.

MS+MiniScript+
1PRINT 2 + 3 * 42PRINT (2 + 3) * 43PRINT 20 DIV 3 * 2

The results are 14, 20, 12. Use NOT (a == b) to negate a comparison explicitly.

Comparisons and logic#

== checks equality and != checks inequality. Numbers also support <, <=, >, >=. Assignment uses one =, equality uses two. Equality respects types: the number 3 differs from the string "3".

ABA AND BA OR B
FALSEFALSEFALSEFALSE
FALSETRUEFALSETRUE
TRUEFALSEFALSETRUE
TRUETRUETRUETRUE

NOT reverses a Boolean. Express an interval as x >= 2 AND x <= 8, not 2 <= x <= 8. AND and OR short-circuit: when the left operand decides the result, the right operand is not evaluated. In b != 0 AND a / b > 2, the left check protects the division. Order matters: do not put the division before the check.

Numeric functions#

ABS(x) gives the absolute value. INT(x) and TRUNC(x) remove the fractional part toward zero; FLOOR(x) rounds down. ROUND(x) rounds to an integer; ROUND(x, 2) rounds to two decimal places. Ties round toward positive infinity: ROUND(-1.5) is -1. Numbers have finite precision: avoid exact equality between calculated fractions and keep exact integers within ±9007199254740991.

Practice#

  1. Split 37 minutes into complete hours and remaining minutes: 0 and 37.
  2. Predict 18 DIV 4 + 18 MOD 4, then check: 6.
  3. Write a condition for a positive even number. Continue with conditions.
PreviousVariablesNextInput and output

On this page

ArithmeticEvaluation orderComparisons and logicNumeric functionsPractice