soma.cell

Math builtins

Math builtins, in the reference of the Soma programming language (soma 3.2.4). A block marked ✓ is a whole program that soma check accepts; the others are excerpts.

abs(-5)             // 5
round(3.7)          // 4
floor(3.7)          // 3
ceil(3.2)           // 4
min(3, 7)           // 3
max(3, 7)           // 7
idiv(7, 2)          // 3 — integer division, truncates toward zero
ln(2.718)           // ~1.0 — natural log (alias of log)
clamp(15, 0, 10)    // 10
pow(2, 10)          // 1024.0
sqrt(16.0)          // 4.0
log(2.718)          // ~1.0
exp(1.0)            // ~2.718
log10(100.0)        // 2.0
random()            // float 0.0..1.0
random(100)         // int 0..99
random(10, 20)      // int 10..19