Float
1.234 # 1.234
.1234 # 0.1234
1234e-5 # 0.01234
12.34e5 # 12340000.1 + 0.2 == 0.3 # true1.234.float # conversion to floating-point numbervar x = 3/4 # rational
var y = 0.9.float # floating-point
var z = x+y # floating-pointsay sqrt(2) # 1.41421356237309504880168872420969807856967187538
local Num!PREC = 24 # number of bits of precision
say sqrt(2) # 1.41421func my_sqrt(n) {
sqrt(n)
}
say my_sqrt(2) # 1.41421356237309504880168872420969807856967187538
do { # creates a new scope
local Num!PREC = 24 # changes the floating-point precision locally
say my_sqrt(2) # 1.41421
} # the default precision is restored when the scope ends
say my_sqrt(2) # 1.41421356237309504880168872420969807856967187538Last updated