Perl module to convert between MB/GB/TB without converting to bytes first? -


i'm trying calculate free space on lvm physical volume multiplying number of free physical extents extent size, example:

3623365 free extents * 4.00 mb each = 13.8 tb 

i using number::format convert extent size bytes , convert results of multiplication human-readable string, tb , higher not supported, end longer, less readable 14,153.8 gb.

according docs, reason tb , not supported because of integer overflows on 32-bit systems, made me wonder if should multiplying arbitrary large numbers without using math::bigint. see number::bytes::human supports numbers yb (yottabytes), it's still in alpha hesitate use in production code.

my next thought was, why convert bytes in first place when calculate free space in mb , convert tb? unfortunately, seems neither number::format nor number::bytes::human supports conversions 1 "suffix" another, e.g. mb -> tb. there existing module this? how number::format , number::bytes::human handle both si/non-si units (mb vs. mib), allow set precision, etc. , hesitate roll own solution if full-featured module it.

edit: extent size not in mb, nor free space in tb, not asking how convert mb tb (that trivial). am asking if there existing modules can convert 1 [arbitrary] suffix without converting bytes first.

to convert mb tb w/o going through bytes:

number of tb = number of mb * (bytes in 1 tb/bytes in 1 mb)


update: generalize:

number of new units = number of old units * (bytes in 1 new unit / bytes in 1 old unit)


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -