Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: GB, MB, KB and on..

by Stevie-O (Friar)
on Jul 30, 2004 at 00:33 UTC ( #378563=note: print w/ replies, xml ) Need Help??

in reply to GB, MB, KB and on..

# will need adjustment if you want to do negative values # kbstring(1024) => 1KB # MS uses a threshold of 0.98. I find this to be a perfectly # acceptable threshold. 0.98*1024 == 1003. sub kbstring { my $value = shift; my @prefix = ('', qw(K M G T)); while (@prefix>1 && $value >= 1000) { shift @prefix; $value /= 1024; } return sprintf '%.2fdsB', $value, $prefix[0]; }
$"=$,,$_=q>|\p4<6 8p<M/_|<('=> .q>.<4-KI<l|2$<6%s!<qn#F<>;$, .=pack'N*',"@{[unpack'C*',$_] }"for split/</;$_=$,,y[A-Z a-z] {}cd;print lc

Comment on Re: GB, MB, KB and on..
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://378563]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (11)
As of 2015-12-01 14:39 GMT
Find Nodes?
    Voting Booth?

    My keyboard shows this many letters:

    Results (12 votes), past polls