大小以千字节为单位? [英] size in kbytes?

查看:76
本文介绍了大小以千字节为单位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我分配一些size_t的内存,但想表达:


printf("分配的内存总量是:%lu bytes.\ n,(unsigned

long)total_mem);


,以千字节为单位。方法1或2是正确的吗?我已经看过两个

解释使用谷歌:


1)

printf("分配的内存总量是:%lu kb.\ n",(unsigned long)

total_mem / 1024);


2)

printf (分配的内存总量为:%lu kb.\ n,(unsigned long)

total_mem / 1000);


祝你好运/ Med venlig hilsen

Martin J?rgensen


-

------------ -------------------------------------------------- -------------

Martin J?rgensen的家 - http://www.martinjoergensen.dk

解决方案

Martin J?rgensen写道:



我分配了一些size_t的内存,但是想表达一下:

printf(分配的内存总量是:%lu bytes.\ n ,(未签名
长)total_mem);
以千字节为单位。方法1或2是正确的吗?我已经看过两个使用google的解释:




取决于你对kilobyte的定义
http://en.wikipedia.org/wiki/Kilobyte


< blockquote>" Martin J?rgensen" <未********* @ spam.jay.net>在消息中写道

news:ra ************ @ news.tdc.dk ...



我分配了一些size_t的内存,但想表达:

printf(分配的内存总量是:%lu bytes.\ n,(unsigned
long) total_mem);

以千字节为单位。方法1或2是正确的吗?我已经看过两个使用谷歌的解释:

printf(分配的内存总量是:%lu kb.\,(无符号)长)
total_mem / 1024);

2)
printf(分配的内存总量为:%lu kb.\ n,(unsigned long)
total_mem / 1000);




在数据存储上下文中,前缀K通常等于1024,而在网络

传输上下文中它可能是等于1000.前缀Ki设置为1024,因此1 KiB =

1024字节。


Nils O. Sel?sdal写道:< blockquote class =post_quotes> Martin J?rgensen写道:



我分配了一些size_t的内存,但想表达:

printf(分配的内存总量为:%lu bytes.\ n,(unsigned
long)total_mem);

以千字节为单位。方法1或2是正确的吗?我已经看过两个使用google的解释:



取决于你对kilobyte的定义
http://en.wikipedia.org/wiki/Kilobyte




什么你会用,为什么?什么是正常的?


我认为1024更正确...?

祝你好运/ Med venlig hilsen

Martin J?rgensen


-

----------------------------- ----------------------------------------------

Martin J?rgensen的主页 - http://www.martinjoergensen.dk


Hi,

I allocate some memory of size_t but want to express:

printf("Total amount of allocated memory is: %lu bytes.\n", (unsigned
long) total_mem);

in kilo-bytes. So is method 1 or 2, the correct one? I''ve seen both
explanations using google:

1)
printf("Total amount of allocated memory is: %lu kb.\n", (unsigned long)
total_mem/1024);

2)
printf("Total amount of allocated memory is: %lu kb.\n", (unsigned long)
total_mem/1000);

Best regards / Med venlig hilsen
Martin J?rgensen

--
---------------------------------------------------------------------------
Home of Martin J?rgensen - http://www.martinjoergensen.dk

解决方案

Martin J?rgensen wrote:

Hi,

I allocate some memory of size_t but want to express:

printf("Total amount of allocated memory is: %lu bytes.\n", (unsigned
long) total_mem);

in kilo-bytes. So is method 1 or 2, the correct one? I''ve seen both
explanations using google:



Depends on your definition of kilobyte
http://en.wikipedia.org/wiki/Kilobyte


"Martin J?rgensen" <un*********@spam.jay.net> wrote in message
news:ra************@news.tdc.dk...

Hi,

I allocate some memory of size_t but want to express:

printf("Total amount of allocated memory is: %lu bytes.\n", (unsigned
long) total_mem);

in kilo-bytes. So is method 1 or 2, the correct one? I''ve seen both
explanations using google:

1)
printf("Total amount of allocated memory is: %lu kb.\n", (unsigned long)
total_mem/1024);

2)
printf("Total amount of allocated memory is: %lu kb.\n", (unsigned long)
total_mem/1000);



In data storage context the prefix K usually equals 1024, while in network
transfer context it may equal 1000. The prefix Ki is set to 1024, so 1 KiB =
1024 bytes.


Nils O. Sel?sdal wrote:

Martin J?rgensen wrote:

Hi,

I allocate some memory of size_t but want to express:

printf("Total amount of allocated memory is: %lu bytes.\n", (unsigned
long) total_mem);

in kilo-bytes. So is method 1 or 2, the correct one? I''ve seen both
explanations using google:


Depends on your definition of kilobyte
http://en.wikipedia.org/wiki/Kilobyte



What would you use and why? What''s "normal" ?

I think 1024 is more correct...?
Best regards / Med venlig hilsen
Martin J?rgensen

--
---------------------------------------------------------------------------
Home of Martin J?rgensen - http://www.martinjoergensen.dk


这篇关于大小以千字节为单位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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