div
, and mod
. div
rounds toward negative infinity (defined as floor[x/y]
). mod
uses the sign of the second number (defined as x - y * floor[x/y]
). All operators automatically produce big integers or exact rational numbers when necessary.
[a,b] = input["Enter numbers",["a","b"]]
ops=["+", "-", "*", "/", "div" ,"mod" ,"^"]
for op = ops
{
str = "$a $op $b"
println["$str = " + eval[str]]
}