Added a bunch of built-in methods

This commit is contained in:
Teascade 2017-08-27 22:31:24 +00:00
parent 992c7b6009
commit af570e6b63
1 changed files with 37 additions and 1 deletions

View File

@ -459,7 +459,43 @@ if (int_opt?) {
## Built-in functions
- [`print(text: string)`](#print-text-string)
- [`print(text: string)`](#printtext-string)
- [`floor(number: T) -> T`](#floornumber-t-t)
- [`ceil(number: T) -> T`](#floornumber-t-t)
- [`round(number: T) -> T`](#roundnumber-t-t)
- [`sqrt(number: T) -> T`](#sqrtnumber-t-t)
- [`pow(number: T, exponent: N) -> T`](#pownumber-t-exponent-n)
- [`random() -> f32`](#random-f32)
- [`time_now() -> i32`](#time-now-i32)
- [`random64() -> f64`](#random64-f64)
- [`time_now64() -> i64`](#time-now64-i64)
#### `print(text: string)`
Prints `text` to standard (stdout, to console by default). This is configurable by changing stdout in the Omega VM.
#### `floor(number: T) -> T`
Floors `number` (rounding downwards), where T is either `f32` or `f64`, and then returns the value of the floor of that same type.
#### `ceil(number: T) -> T`
Ceils `number` (rounding upwards), where T is either `f32` or `f64`, and then returns the value of the ceil of that same type.
#### `round(number: T) -> T`
Rounds `number`, where T is either `f32` or `f64`, and then returns the value of the round of that same type.
#### `sqrt(number: T) -> T`
Returns the square root of `number`, where T is either `f32` or `f64`.
#### `pow(number: T, exponent: N) -> T`
Returns the power of `number` to the exponent of `exponent`, where T and N is either `i16`, `i32`, `i64`, `f32` or `f64`.
#### `random() -> f32`
Returns a random number between 0 and 1.
#### `time_now() -> i32`
Returns the current time in milliseconds since January 1st 1970.
#### `random64() -> f64`
Functions like [`random() -> f32`](#random-f32), except it returns a more accurate f64.
#### `time_now64() -> i64`
Returns the current time in nanoseconds since January 1st 1970.