From af570e6b63ed4080237f22d6f2aeb501b7c6ae1b Mon Sep 17 00:00:00 2001 From: Teascade Date: Sun, 27 Aug 2017 22:31:24 +0000 Subject: [PATCH] Added a bunch of built-in methods --- README.md | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ecf02e9..d5493fd 100644 --- a/README.md +++ b/README.md @@ -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.