Fix typo for randd and randf

* And improve documentation according to issue #25938
This commit is contained in:
Pierrick Brunet 2019-02-16 21:05:18 +01:00
parent 274d7cd632
commit 3b6d05db3e
2 changed files with 5 additions and 5 deletions

View file

@ -242,8 +242,8 @@ public:
static void randomize(); static void randomize();
static uint32_t rand_from_seed(uint64_t *seed); static uint32_t rand_from_seed(uint64_t *seed);
static uint32_t rand(); static uint32_t rand();
static _ALWAYS_INLINE_ double randf() { return (double)rand() / (double)Math::RANDOM_MAX; } static _ALWAYS_INLINE_ double randd() { return (double)rand() / (double)Math::RANDOM_MAX; }
static _ALWAYS_INLINE_ float randd() { return (float)rand() / (float)Math::RANDOM_MAX; } static _ALWAYS_INLINE_ float randf() { return (float)rand() / (float)Math::RANDOM_MAX; }
static double random(double from, double to); static double random(double from, double to);
static float random(float from, float to); static float random(float from, float to);

View file

@ -809,7 +809,7 @@
<argument index="1" name="to" type="float"> <argument index="1" name="to" type="float">
</argument> </argument>
<description> <description>
Random range, any floating point value between [code]from[/code] and [code]to[/code]. Random range, any floating point value in the interval [[code]from[/code], [code]to[/code]].
[codeblock] [codeblock]
prints(rand_range(0, 1), rand_range(0, 1)) # prints 0.135591 0.405263 prints(rand_range(0, 1), rand_range(0, 1)) # prints 0.135591 0.405263
[/codeblock] [/codeblock]
@ -828,7 +828,7 @@
<return type="float"> <return type="float">
</return> </return>
<description> <description>
Returns a random floating point value between 0 and 1. Returns a random floating point value on the interval [0, 1].
[codeblock] [codeblock]
randf() # returns 0.375671 randf() # returns 0.375671
[/codeblock] [/codeblock]
@ -838,7 +838,7 @@
<return type="int"> <return type="int">
</return> </return>
<description> <description>
Returns a random 32 bit integer. Use remainder to obtain a random value between 0 and N (where N is smaller than 2^32 -1). Returns a random 32 bit integer. Use remainder to obtain a random value in the interval [0, N] (where N is smaller than 2^32 -1).
[codeblock] [codeblock]
randi() % 20 # returns random number between 0 and 19 randi() % 20 # returns random number between 0 and 19
randi() % 100 # returns random number between 0 and 99 randi() % 100 # returns random number between 0 and 99