Numbers in langur are decimal floating point.

As of 0.8, langur uses a modified version of, a native Go library with arbitrary precision. Prior to 0.8, langur uses Mike Cowlishaw's decimal C library, via the Go wrapper library

number literals

Numbers in base 10 may be specified without qualification, such as 100 or 123.456.

Number literals may use underscores for visual clarity (such as 3_000_000), but cannot start with an underscore.

E-notation may be used, such as 1.234e+1000. It always requires a + or - after the e.

Rounding defaults to half away from zero. Prior to 0.11, it defaults to round half even. 0.11 allows you to use either of these modes.

The division maximum scale (digits after a decimal point) defaults to 33, but this can be set to something else. Being arbitrary precision, there has to be a set stopping point for division.

mode divMaxScale = 7000 # sets max digits after decimal (for division) to 7000

basex notation

Integer literals may use basex notation, such as 16xFF or 2x1010_0010 or -11x123.

Any base from 2 to 36 may be used, using the ASCII alphabet for digits higher than 9 (uppercase or lowercase).

At this time, basex notation is available for integers within the range of a signed 64-bit int.

math operators

+ add
- subtract
x multiply
/ divide
\ truncating division
// floor division
rem remainder
mod modulus
div divisible by
ndiv not divisible by
^ exponent (right-associative)
^/ root (right-associative)

Also see the operators page, which lists all operators with their precedence and associativity.

roots and exponents

Integer roots and exponents may be calculated in the current implementation, but the left-hand operand can be a floating point number.

The root operator is very flexible, but when the result uses the full scale available (as determined by the divMaxScale mode), the last few digits might be taken as an approximation at this time.


The floor division operator // may give different results than the truncating division operator \ if one of the operands is negative. See the following helpful link about floor division.

remainder and modulus

Remainder (rem) and modulus (mod) are not the same operator, but for positive operands will return the same result. You typically want to use the rem operator. The mod operator involves more calculation.


The following constants are available by using the keyword.

pi Archimedes' constant
phi the Golden Ratio
e Euler's number
n2 natural logarithm of 2
n10 natural logarithm of 10

So, to calculate the circumference of a circle with radius of 7, you could use the following.

# 2𝛑r 14 x pi # result == 43.98229715025710533847700736591304037876037159125148149364922429230942968800692598079248755478963895174996