Difference between revisions of "Talk:Pseudo-random Number Generator"

From Second Life Wiki
Jump to navigation Jump to search
(New page: rand can be optimized to and will be mono safe as... <pre> integer rand(integer spread) { seed2 = (seed2 * seed2Mod + 0xB); return (seed1Mod = ((seed1 = (seed1 * (seed2Mod = seed1Mod...)
 
Line 6: Line 6:
}
}
</pre> -- [[User:Strife Onizuka|Strife Onizuka]] 11:25, 21 November 2007 (PST)
</pre> -- [[User:Strife Onizuka|Strife Onizuka]] 11:25, 21 November 2007 (PST)
: I like to try to keep the code human-readable at first, but I'll add this as the optimized version. Thanks --[[User:Xaviar Czervik|Xaviar Czervik]] 09:55, 26 November 2007 (PST)

Revision as of 09:55, 26 November 2007

rand can be optimized to and will be mono safe as...

integer rand(integer spread) {
    	seed2 = (seed2 * seed2Mod + 0xB);
	return (seed1Mod = ((seed1 = (seed1 * (seed2Mod = seed1Mod) + 0xB)) * seed2)) % spread;
}

-- Strife Onizuka 11:25, 21 November 2007 (PST)

I like to try to keep the code human-readable at first, but I'll add this as the optimized version. Thanks --Xaviar Czervik 09:55, 26 November 2007 (PST)