Handbook · Reference · Blockly · Math

Blockly: Math

Where in the UI. Scripts tab toolbox.

Stock math plus Containd rounding, hex color ints, and random lists.

Block idRead asPurpose
math_numbernumberNumber literal.
math_arithmeticarithmeticAdd, subtract, multiply, divide, power.
math_singlesingleSqrt, abs, negate, ln, log10, exp, trig inverses as listed on the block.
math_trigtrigSin, cos, tan, and inverses.
math_constantconstantπ, e, golden ratio, sqrt(2), sqrt(½), ∞.
math_roundroundRound, round up, round down.
containd_round_max_digitsround max digitsRound to at most N significant digits (e.g. 37.658→37.7 at N=3). When |value| ≥ 10^N, Math.round only (keeps all integer digits). No host call.
containd_hex_color_to_inthex color to intPack #RRGGBB / #RRGGBBAA (alpha last) to unsigned 32-bit 0xRRGGBBAA.
containd_int_to_hex_colorint to hex colorUnpack unsigned 32-bit 0xRRGGBBAA to #RRGGBB (opaque) or #RRGGBBAA.
math_modulomoduloRemainder of division.
math_constrainconstrainClamp a number between bounds.
math_random_intrandom intRandom integer in a range.
containd_random_floatrandom floatSandbox Math.random — no host call
containd_random_int_listrandom int listSandbox Math.random — array of n inclusive ints (no host call)
containd_random_float_listrandom float listSandbox Math.random — array of n decimals (no host call)