计算字节数/ KB / MB / Gb ...... [英] Calculating Bytes/KB/MB/Gb...

查看:111
本文介绍了计算字节数/ KB / MB / Gb ......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有长变量,包含存储的字节数。

我想显示字节数,KB,MB,GB,具体取决于此变量的大小

作为一个字符串。

框架是否为这样的快速计算提供任何类,或者我必须将
除以1024,检查结果是否为零,如果不再划分等等......?

谢谢

PK

Hi
I have long variable containing number of stored bytes.
I want to display Bytes , KB, MB, GB depending of the size of this variable
as a string.
Does framework provide any class for such a fast calculation or i have to
divide by 1024, check if result is zero, if not divide again and so on...?
Thanks
PK

推荐答案

PiotrKolodziej< pi ************* @ gmail.comwrote:
PiotrKolodziej <pi*************@gmail.comwrote:



我很久包含存储字节数的变量。

我想显示字节数,KB,MB,GB,具体取决于此变量的大小

作为字符串。

框架是否为这种快速计算提供任何类别,或者我必须将
除以1024,检查结果是否为零,如果不再划分等等......?
Hi
I have long variable containing number of stored bytes.
I want to display Bytes , KB, MB, GB depending of the size of this variable
as a string.
Does framework provide any class for such a fast calculation or i have to
divide by 1024, check if result is zero, if not divide again and so on...?



bytes / 1024 == KB

bytes / 1024 ^ 2 == MB

bytes / 1024 ^ 3 == GB

bytes / 1024 ^ 4 == TB


-

Thomas T. Veldhouse

主要指纹:2DB9 813F F510 82C2 E1AE 34D0 D69D 1EDC D5EC AED1

bytes / 1024 == KB
bytes / 1024^2 == MB
bytes / 1024^3 == GB
bytes / 1024^4 == TB

--
Thomas T. Veldhouse
Key Fingerprint: 2DB9 813F F510 82C2 E1AE 34D0 D69D 1EDC D5EC AED1



bytes / 1024 == KB

bytes / 1024 ^ 2 == MB

bytes / 1024 ^ 3 == GB

bytes / 1024 ^ 4 == TB
bytes / 1024 == KB
bytes / 1024^2 == MB
bytes / 1024^3 == GB
bytes / 1024^4 == TB



这不是我的问题的答案。

It''s not the answer for my question.


PiotrKolodziej< pi ****** *******@gmail.com写道:
PiotrKolodziej <pi*************@gmail.comwrote:

>
>

> bytes / 1024 == KB
bytes / 1024 ^ 2 == MB
bytes / 1024 ^ 3 == GB
bytes / 1024 ^ 4 == TB
>bytes / 1024 == KB
bytes / 1024^2 == MB
bytes / 1024^3 == GB
bytes / 1024^4 == TB



这不是我的问题的答案。


It''s not the answer for my question.



我认为我的答案是不。


如果你愿意,你可以自己编写格式提供者。


- < br $>
Thomas T. Veldhouse

主要指纹:2DB9 813F F510 82C2 E1AE 34D0 D69D 1EDC D5EC AED1

I think my answer was "No".

You can write your own FormatProvider if you wish.

--
Thomas T. Veldhouse
Key Fingerprint: 2DB9 813F F510 82C2 E1AE 34D0 D69D 1EDC D5EC AED1


这篇关于计算字节数/ KB / MB / Gb ......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆