<?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/16818" />

	<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>2009-04-19T09:28:22-04:00</updated>

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

		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-04-19T09:28:22-04:00</updated>

		<published>2009-04-19T09:28:22-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88507#p88507</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88507#p88507"/>
		<title type="html"><![CDATA[Problem with formating units]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88507#p88507"><![CDATA[
Could you verify that $value is indeed an integer and not a float?<br><br>The code posted by speechles relies on integer division, and will fail if either the nominator or the denominator is a float. I'd also recommend adding a constraint to the value of unit, as to prevent it from going out of bounds for the "suffix-list".<br>You might be able to get away with forcing $test to an integer in the beginning.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sun Apr 19, 2009 9:28 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[aRTiST]]></name></author>
		<updated>2009-04-19T05:25:50-04:00</updated>

		<published>2009-04-19T05:25:50-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88502#p88502</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88502#p88502"/>
		<title type="html"><![CDATA[hm]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88502#p88502"><![CDATA[
I tried with ur version, but now ill get an error :<br><div class="codebox"><p>Code: </p><pre><code>floating-point value too large to represent</code></pre></div>:/<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10602">aRTiST</a> — Sun Apr 19, 2009 5:25 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[speechles]]></name></author>
		<updated>2009-04-18T23:22:31-04:00</updated>

		<published>2009-04-18T23:22:31-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88500#p88500</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88500#p88500"/>
		<title type="html"><![CDATA[Problem with formating units]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88500#p88500"><![CDATA[
The problem here is your method of attaining size doesn't match throughout your procedure. You initially set "len" to the [string length $value]. Then you set "unit" to to "($len-1) / 3". This where you make your mistake. This assumes 1,000 for our divisor. Yet below that you make use of the correct 1,024 to raise powers which throws off the entire equation. Using the method below should solve your problem and its more compact.<br><div class="codebox"><p>Code: </p><pre><code>proc format_1024_units {value} { set test $value ; set unit 0while {[set test [expr {$test / 1024}]] &gt; 0} {incr unit}return [format "%.1f %s" [expr {$value / pow(1024,$unit)}] [lindex [list B KB MB GB TB PB EB ZB YB] $unit]]}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8138">speechles</a> — Sat Apr 18, 2009 11:22 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[aRTiST]]></name></author>
		<updated>2009-04-18T13:58:14-04:00</updated>

		<published>2009-04-18T13:58:14-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88495#p88495</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88495#p88495"/>
		<title type="html"><![CDATA[Problem with formating units]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88495#p88495"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>proc format_1024_units {value} {set len [string length $value]if {$value &lt; 1024} {return [format "%s B" $value]} else {set unit [expr {($len - 1) / 3}]return [format "%.1f %s" [expr {$value / pow(1024,$unit)}] [lindex [list B KB MB GB TB PB EB ZB YB] $unit]]}}</code></pre></div>But the result is then often 0.0TB (value is really 35.2GB unformated).<br><br>Any hints where im doing wrong ?<br><br>TIA arti<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10602">aRTiST</a> — Sat Apr 18, 2009 1:58 pm</p><hr />
]]></content>
	</entry>
	</feed>
