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

Re: GB, MB, KB and on..

by Joost (Canon)
on Jul 29, 2004 at 23:26 UTC ( [id://378544]=note: print w/replies, xml ) Need Help??


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

Take advantage of the fact that 1 Gb = 1024 Mb, 1 Mb = 1024 Kb and 1024 = 2 ** 10:
my $kb = 1024 * 1024; # set to 1 Gb my $mb = $kb >> 10; my $gb = $mb >> 10; print "$kb kb = $mb mb = $gb gb\n"; __END__ 1048576 kb = 1024 mb = 1 gb
Edit: after reading your post again, I'm afraid it doesn't really do what you want (though I think it's pretty elegant), because it will round down to the nearest integer.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-24 02:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found