summaryrefslogtreecommitdiff
path: root/nuttx/libc
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-12-01 18:44:57 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-12-01 18:44:57 +0000
commit4a52ec4022805eae6529ebe8c5b9c7bdff1a87e9 (patch)
treea5e47310d3d2e5ab1449198a656f823e92bff3df /nuttx/libc
parent8da9aa0f9aadaf51aabbb64fadc1ea7d9f9bc6a0 (diff)
downloadpx4-nuttx-4a52ec4022805eae6529ebe8c5b9c7bdff1a87e9.tar.gz
px4-nuttx-4a52ec4022805eae6529ebe8c5b9c7bdff1a87e9.tar.bz2
px4-nuttx-4a52ec4022805eae6529ebe8c5b9c7bdff1a87e9.zip
Another random number generator update
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5406 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/libc')
-rw-r--r--nuttx/libc/stdlib/lib_rand.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/nuttx/libc/stdlib/lib_rand.c b/nuttx/libc/stdlib/lib_rand.c
index 465cce47f..bbefaee5d 100644
--- a/nuttx/libc/stdlib/lib_rand.c
+++ b/nuttx/libc/stdlib/lib_rand.c
@@ -175,13 +175,13 @@ static inline void fgenerate2(void)
unsigned long randint;
/* Second order congruential generator. One may be added to the result of the
- * generated value to avoid the value zero (I am not sure if this is necessor
+ * generated value to avoid the value zero (I am not sure if this is necessary
* for higher order random number generators or how this may effect the quality
* of the generated numbers).
*/
randint = (RND2_CONSTK1 * g_randint1 +
- RND2_CONSTK2 * g_randint2) % RND2_CONSTP + 1;
+ RND2_CONSTK2 * g_randint2) % RND2_CONSTP;
g_randint2 = g_randint1;
g_randint1 = (randint == 0 ? 1 : randint);
@@ -208,14 +208,14 @@ static inline void fgenerate3(void)
unsigned long randint;
/* Third order congruential generator. One may be added to the result of the
- * generated value to avoid the value zero (I am not sure if this is necessor
+ * generated value to avoid the value zero (I am not sure if this is necessary
* for higher order random number generators or how this may effect the quality
* of the generated numbers).
*/
randint = (RND3_CONSTK1 * g_randint1 +
RND3_CONSTK2 * g_randint2 +
- RND3_CONSTK2 * g_randint3) % RND3_CONSTP + 1;
+ RND3_CONSTK2 * g_randint3) % RND3_CONSTP;
g_randint3 = g_randint2;
g_randint2 = g_randint1;