11-19-2017, 06:06 +0100
AuthorPost
thommey  10-30-2011, 00:35   | [TCL] Human readable file sizes Jabber
(Administrator)
Member since 03/2004
62 Posts
                                                                                                                              
01
02
03
04
05
06
07
08
09
10
11
# Returns a human readable representation of the "size" argument, which is in bytes
# the second argument specifies the number of digits after the . you want to have

proc humanify {size {digits 2}} {
    foreach prefix {B kiB MiB GiB TiB PiB} {
        set new [expr {$size/1024.0}]
        if {$new < 1} { break }
        set size $new
    }
    return "[format %.*f $digits $size] $prefix"
}

Advanced options for this topic:

Ignore this topic (Do not list this topic in the "unread topics" search. You are currently not ignoring this topic.)
Hide this topic (Hidden topics are not displayed in the topics list. This topic is currently not hidden.)
Go to forum

Unclassified NewsBoard 1.5.3-d | © 2003-4 by Yves Goergen