<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Math.random() &#8211; stoimen&#039;s web log</title>
	<atom:link href="/tag/mathrandom/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>on web development</description>
	<lastBuildDate>Tue, 13 Feb 2018 08:18:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0.3</generator>
	<item>
		<title>JavaScript random numbers</title>
		<link>/2009/05/25/javascript-random-numbers/</link>
		<comments>/2009/05/25/javascript-random-numbers/#comments</comments>
		<pubDate>Mon, 25 May 2009 07:03:29 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[Math.random()]]></category>

		<guid isPermaLink="false">/?p=576</guid>
		<description><![CDATA[The task is &#8230; to generate a random number between any two interger unsigned numbers. Let&#8217;s assume we&#8217;ve two numbers &#8216;a&#8217; and &#8216;b&#8217;, where b &#62; a. (I don&#8217;t count the case with b==a, cause it seems to be pretty strange!). The formula should be like that: Math.random() * (b-a+1) + a Looks very nice, &#8230; <a href="/2009/05/25/javascript-random-numbers/" class="more-link">Continue reading <span class="screen-reader-text">JavaScript random numbers</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2009/03/12/javascript-rounded-corners/" rel="bookmark" title="JavaScript rounded corners">JavaScript rounded corners </a></li>
<li><a href="/2010/08/26/javascript-flexibility-regex-match/" rel="bookmark" title="JavaScript Flexibility &#8211; Regex match()">JavaScript Flexibility &#8211; Regex match() </a></li>
<li><a href="/2011/07/12/a-javascript-trick-you-should-know/" rel="bookmark" title="A JavaScript Trick You Should Know">A JavaScript Trick You Should Know </a></li>
<li><a href="/2009/11/05/browsers-pixels-and-graphic-rendering/" rel="bookmark" title="Browsers, pixels and graphic rendering!">Browsers, pixels and graphic rendering! </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>The task is &#8230;</h2>
<p>to generate a random number between any two interger unsigned numbers. Let&#8217;s assume we&#8217;ve two numbers &#8216;a&#8217; and &#8216;b&#8217;, where b &gt; a. (I don&#8217;t count the case with b==a, cause it seems to be pretty strange!). The formula should be like that:</p>
<blockquote><p>Math.random() * (b-a+1) + a</p></blockquote>
<h2>Looks very nice, but why is that?</h2>
<p>because simply by using Math.random() * a gives a random between 0 and a-1. With the expresion (b-a+1) gives a random number between 0 and (b-a+1) and than by adding the value of a we&#8217;ve the number between a and b.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2009/03/12/javascript-rounded-corners/" rel="bookmark" title="JavaScript rounded corners">JavaScript rounded corners </a></li>
<li><a href="/2010/08/26/javascript-flexibility-regex-match/" rel="bookmark" title="JavaScript Flexibility &#8211; Regex match()">JavaScript Flexibility &#8211; Regex match() </a></li>
<li><a href="/2011/07/12/a-javascript-trick-you-should-know/" rel="bookmark" title="A JavaScript Trick You Should Know">A JavaScript Trick You Should Know </a></li>
<li><a href="/2009/11/05/browsers-pixels-and-graphic-rendering/" rel="bookmark" title="Browsers, pixels and graphic rendering!">Browsers, pixels and graphic rendering! </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2009/05/25/javascript-random-numbers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
