<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/17616" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2010-02-26T19:10:55-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/17616</id>

		<entry>
		<author><name><![CDATA[MIODude]]></name></author>
		<updated>2010-02-26T17:56:53-04:00</updated>

		<published>2010-02-26T17:56:53-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92260#p92260</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92260#p92260"/>
		<title type="html"><![CDATA[[SOLVED] expr / rand / int help]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92260#p92260"><![CDATA[
Thanks <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>I used this one<br>set variable [expr [rand $maxpoint] / 100.0]<br><br>i must have made a mistake when i tried without the int before.. as i was getting some pretty weird numbers<br><br><br>edit: and thanks for clarifying about the {}... i've always been confused on which brackets to use for which things..<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8276">MIODude</a> — Fri Feb 26, 2010 5:56 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2010-02-26T17:41:12-04:00</updated>

		<published>2010-02-26T17:41:12-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92258#p92258</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92258#p92258"/>
		<title type="html"><![CDATA[[SOLVED] expr / rand / int help]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92258#p92258"><![CDATA[
MIODude,<br>Since you want a floating point number returned, why do you convert it to an integer in the first place? Since rand will return an integer between 0 and limit-1, simply dividing it with an appropriate divisor (of type float) should render at most the number of decimals that you desire.<br><div class="codebox"><p>Code: </p><pre><code>set maxpoint 600set variable [expr [rand $maxpoint] / 100.0]</code></pre></div>I suppose I could illustrate the proper way you would use the int function in this case, though you'll find that it does actually nothing in this case, as the random value is already an integer...<br><div class="codebox"><p>Code: </p><pre><code>set maxpoint 6000set variable [expr {int([rand $maxpoint]) * 0.001}]</code></pre></div>This would, however, still return 3 decimals. To sort that, you'd first have to divide the random number by ten, then convert it into an integer, and then divide by one hundred. Also, to properly round up/down, you should really use round() instead of int(), which simply floors the value.<div class="codebox"><p>Code: </p><pre><code>set maxpoint 6000set variable [expr {round([rand $maxpoint] / 10) / 100.0}]</code></pre></div>Finally, be adviced that in such trivial cases like this, you really don't need the {}, as they're only there to prevent "double evaluation", using them won't change much in these simple cases - just remember that if you do use them, you'll have to keep the whole expression within them.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Fri Feb 26, 2010 5:41 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[w00f]]></name></author>
		<updated>2010-02-26T17:21:13-04:00</updated>

		<published>2010-02-26T17:21:13-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92257#p92257</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92257#p92257"/>
		<title type="html"><![CDATA[[SOLVED] expr / rand / int help]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92257#p92257"><![CDATA[
format %.2f &lt;value&gt;<br>will output what you want.<br><br>ie:<br>.format %.2f "5.436987"<br>5.44<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8264">w00f</a> — Fri Feb 26, 2010 5:21 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[MIODude]]></name></author>
		<updated>2010-02-26T19:10:55-04:00</updated>

		<published>2010-02-26T11:39:11-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92250#p92250</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92250#p92250"/>
		<title type="html"><![CDATA[[SOLVED] expr / rand / int help]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92250#p92250"><![CDATA[
Hi Again!<br><br>I keep trying variations of this.. but can't quite get it<br><div class="codebox"><p>Code: </p><pre><code>set maxpoint 6000set variable [expr {int([rand $maxpoint] * .001)}]</code></pre></div>I want the possible values to be 0-6 with 2 decimal places (ie.. 5.23, 4.75, etc)<br><br>the current way i have it, it spits out only whole numbers (I'm assuming because the int is outside of everything.. but if I try to put .001 outside of the {}, i get errors like "invalid bareword "int"", or "can't use non-numeric string as operand of "*"<br><br>i have the int in there so I can control the number of decimal places (else it comes out with things like 3.54338238)<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8276">MIODude</a> — Fri Feb 26, 2010 11:39 am</p><hr />
]]></content>
	</entry>
	</feed>
