Numbers & arithmetic
Numbers are 64-bit floats, Int is a 64-bit integer, and Bool holds truth values. Run a cell to see its output beside the expected one.
Integer literals are floats
10 is read as 10.0, so division never truncates.
print vs show
print gives the bare value. show labels a variable with its name, and prints any other expression bare, as print would.
Scientific notation
Compound assignment
x += 1 means x = x + 1, and the same holds for -=, *= and /=.
The math builtins
29 functions. pow, atan2, hypot, copysign and mod take two arguments, fma takes three, min and max take two or more, and fsum gives the correctly rounded sum of an array. mod is C's fmod.
erf and gamma
The engines agree to double precision; gamma(5) is 4! and gamma(1/2) is √π.
Precedence
Multiplication binds tighter than addition; parentheses override.
Division by zero and sqrt of a negative
Following IEEE float rules, these give inf and nan instead of stopping the program.
mod with negatives
mod is C's fmod: the result takes the sign of the first argument.
round halves go away from zero
round follows C: halves round away from zero, so 2.5 gives 3 and -2.5 gives -3, not the nearest even number.
pow(0, 0) is 1
pow(0, 0) returns 1, as C does.
atan2 knows the quadrant
atan2(y, x) uses the signs of both arguments to return the angle in the correct quadrant.
abs, min, max
The hyperbolics and inverse trig
% and // round toward minus infinity
a % b takes the sign of b and a // b is the floor of the quotient, as in Python, so a == (a // b) * b + a % b. mod(a, b) is C's fmod and keeps the sign of a.
^ is pow
x ^ y is pow(x, y). It binds tighter than a minus on its left, so -3 ^ 2 is -9, and it groups from the right.