diff --git a/config/docs.cfg b/config/docs.cfg index fa570668..8f629b71 100644 --- a/config/docs.cfg +++ b/config/docs.cfg @@ -130,6 +130,12 @@ docargument [A] [action] [] [0]; docexample [p = 1; push p 2; echo $p] [Output: 2]; docident [result] [sets the result value of a CubeScript block]; docargument [R] [the result] [] [0]; +docident [round] [Round a float and returns an integer]; +docargument [F] [The float number to be rounded] [] [0]; +docident [ceil] [Return the ceil value (integer) of a float]; +docargument [F] [The float number] [] [0] +docident [floor] [Return the floor value (integer) of a float]; +docargument [F] [The float number] [] [0] docident [rnd] [Random value]; docargument [A] [The upper limit of the random value] [] [0]; docident [rrnd] [Ranged random value]; diff --git a/docs/reference.xml b/docs/reference.xml index deedb68d..e87727b6 100644 --- a/docs/reference.xml +++ b/docs/reference.xml @@ -378,6 +378,30 @@ + + Round the given float + + + + + + + + Upper value of a float number + + + + + + + + Floor value of a float number + + + + + + Determines if two strings are equal. diff --git a/source/src/command.cpp b/source/src/command.cpp index 1bf64a00..2956432a 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -1272,6 +1272,11 @@ int lt(int a, int b) { return (int)(ab); } COMMANDN(>, gt, ARG_2EXP); int lte(int a, int b) { return (int)(a<=b); } COMMANDN(<=, lte, ARG_2EXP); int gte(int a, int b) { return (int)(a>=b); } COMMANDN(>=, gte, ARG_2EXP); + +COMMANDF(round, ARG_1STR, (char *a) { intret((int)round(atof(a))); }); +COMMANDF(ceil, ARG_1STR, (char *a) { intret((int)ceil(atof(a))); }); +COMMANDF(floor, ARG_1STR, (char *a) { intret(atoi(a)); }); + #define COMPAREF(opname, func, op) \ void func(char *a, char *b) { intret((int)(atof(a) op atof(b))); } \ COMMANDN(opname, func, ARG_2STR)