Another random number generator update

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5406 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-12-01 18:44:57 +00:00
parent 131684fb54
commit 65548d2ae0
2 changed files with 5 additions and 5 deletions

View File

@ -970,7 +970,7 @@ static int ug2864ambag01_setcontrast(struct lcd_dev_s *dev, unsigned int contras
*/ */
#if CONFIG_LCD_MAXCONTRAST != 255 #if CONFIG_LCD_MAXCONTRAST != 255
newcontrast = ((contrast << 8) - 1) / CONFIG_LCD_MAXCONTRAST; scaled = ((contrast << 8) - 1) / CONFIG_LCD_MAXCONTRAST;
#else #else
scaled = contrast; scaled = contrast;
#endif #endif

View File

@ -175,13 +175,13 @@ static inline void fgenerate2(void)
unsigned long randint; unsigned long randint;
/* Second order congruential generator. One may be added to the result of the /* 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 * for higher order random number generators or how this may effect the quality
* of the generated numbers). * of the generated numbers).
*/ */
randint = (RND2_CONSTK1 * g_randint1 + randint = (RND2_CONSTK1 * g_randint1 +
RND2_CONSTK2 * g_randint2) % RND2_CONSTP + 1; RND2_CONSTK2 * g_randint2) % RND2_CONSTP;
g_randint2 = g_randint1; g_randint2 = g_randint1;
g_randint1 = (randint == 0 ? 1 : randint); g_randint1 = (randint == 0 ? 1 : randint);
@ -208,14 +208,14 @@ static inline void fgenerate3(void)
unsigned long randint; unsigned long randint;
/* Third order congruential generator. One may be added to the result of the /* 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 * for higher order random number generators or how this may effect the quality
* of the generated numbers). * of the generated numbers).
*/ */
randint = (RND3_CONSTK1 * g_randint1 + randint = (RND3_CONSTK1 * g_randint1 +
RND3_CONSTK2 * g_randint2 + RND3_CONSTK2 * g_randint2 +
RND3_CONSTK2 * g_randint3) % RND3_CONSTP + 1; RND3_CONSTK2 * g_randint3) % RND3_CONSTP;
g_randint3 = g_randint2; g_randint3 = g_randint2;
g_randint2 = g_randint1; g_randint2 = g_randint1;