Numbers
There are two types of numbers in Gren: integers and floating point.
Integers have the type Int and represent a whole number:
myInt : IntmyInt = 42Floating point numbers have the type Float and are an approximation of a fractional number:
myFloat : FloatmyFloat = 8.67Gren also has a special number type that can represent both.
You may have seen it in the repl:
> gren repl---- Gren 0.5.0 -----------------------------------------------------------------Say :help for help and :exit to exit!--------------------------------------------------------------------------------> 123123 : numberYou can use this for type signatures where it doesn’t matter if something is an Int or a Float:
double : number -> numberdouble n = n * 2Math
You can perfrom basic math operations on numbers using the typical operators:
> 1 + 23 : number> 2 - 11 : number> 2 * 36 : number> 6 / 23 : FloatNotice that the division operator returns floats:
> 6 / 41.5 : FloatYou can perform integer division with //:
> 6 // 41 : IntFor exponentation, use ^:
> 3 ^ 29 : numberFor other math operations, see the Math module documentation.