b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

t和unsigned int转换的数据丢失是多少?

电脑杂谈  发布时间:2019-11-05 09:04:19  来源:网络整理

size-t和unsigned int_unsigned int和nsuinteger_int/int

> 其他开发 > 'uintmax_t'到'size_t'和'unsigned int'转换的数据丢失是多少?(What is the loss of data in 'uintmax_t' to 'size_t' and 'unsigned int' conversion?)

其他开发IT屋2018/8/6 19:56:25

百度翻译此文有道翻译此文

问 题

I get this:

warning 244: 'initializing' : conversion from 'uintmax_t' to 'unsigned int', possible loss of data

on:

boost::shared_array<char> buffer( new char[file->size]);

…and then this:

warning 244: 'argument' : conversion from 'uintmax_t' to 'size_t', possible loss of data

on:

boost::asio::write(*socket, boost::asio::buffer(buffer.get(), file->size));

Shall I be scared or it is ok?

int/int_unsigned int和nsuinteger_size-t和unsigned int

解决方案

Probably file->size is of type uintmax_t which is larger than the size_t that operator new[] takes for the array size. Typically the first one could be a 64bit integer while the second one would only be a 32bit.

Practically this will lead to problems when you are trying to handle files over 4GB, because the size_t can't represent such a large number of bytes. If you only expect to handle smaller files where size_t is large enough to store the file size, there won't be a problem.

本文地址:IT屋 What is the loss of data in &#39;uintmax_t&#39; to &#39;size_t&#39; and &#39;unsigned int&#39; conversion?

问 题

我知道了:

警告244:'初始化':从'uintmax_t'转换为'unsigned int',可能会丢失数据

on:

 升压:: shared_array&LT;炭&GT; buffer(new char [file-> size]); 

...然后这个:

警告244:'参数':从'uintmax_t'转换为'size_t',可能丢失数据

on:

  boost :: asio :: write(* socket,boost :: asio :: buffer(buffer.get() ,file-> size)); 

int/int_size-t和unsigned int_unsigned int和nsuinteger

我会担心还是没事?

解决方案

可能 file-> size 的类型为 uintmax_t 大于 size_t ,运算符new [] 占用数组大小。通常,第一个可能是64位整数,而第二个只能是32位。

实际上,当您尝试处理达到4GB的文件时,这会导致问题size-t和unsigned int,因为 size_t 不能代表这么长期的字节。如果您只期望处理较小的文件,其中 size_t 足以存储文件大小,则不会出现问题。

本文地址:IT屋 'uintmax_t'到'size_t'和'unsigned int'转换的数据丢失是多少?

官方微信

扫一扫关注IT屋

微信公众号搜索 “ IT屋 ” ,选择关注

与百万开发者在一起

官方交流群:IT屋-技术交流群③

Google Facebook Youtube 科学上网》戳这里《

百度翻译此文有道翻译此文

问 题

int/int_unsigned int和nsuinteger_size-t和unsigned int

我知道了:

警告244:'初始化':从'uintmax_t'转换为'unsigned int'size-t和unsigned int,可能会丢失数据

on:

 升压:: shared_array&LT;炭&GT; buffer(new char [file-> size]); 

...然后这个:

警告244:'参数':从'uintmax_t'转换为'size_t',可能丢失数据

on:

  boost :: asio :: write(* socket,boost :: asio :: buffer(buffer.get() ,file-> size)); 

我会担心还是没事?

解决方案

可能 file-> size 的类型为 uintmax_t 大于 size_t ,运算符new [] 占用数组大小。通常,第一个可能是64位整数,而第二个只能是32位。

实际上,当您尝试处理达到4GB的文件时,这会导致问题,因为 size_t 不能代表这么长期的字节。如果您只期望处理较小的文件,其中 size_t 足以存储文件大小,则不会出现问题。

本文地址:IT屋 'uintmax_t'到'size_t'和'unsigned int'转换的数据丢失是多少?

int/int_size-t和unsigned int_unsigned int和nsuinteger

问 题

I get this:

warning 244: 'initializing' : conversion from 'uintmax_t' to 'unsigned int', possible loss of data

on:

boost::shared_array<char> buffer( new char[file->size]);

…and then this:

warning 244: 'argument' : conversion from 'uintmax_t' to 'size_t', possible loss of data

on:

boost::asio::write(*socket, boost::asio::buffer(buffer.get(), file->size));

Shall I be scared or it is ok?

解决方案

Probably file->size is of type uintmax_t which is larger than the size_t that operator new[] takes for the array size. Typically the first one could be a 64bit integer while the second one would only be a 32bit.

Practically this will lead to problems when you are trying to handle files over 4GB, because the size_t can't represent such a large number of bytes. If you only expect to handle smaller files where size_t is large enough to store the file size, there won't be a problem.

本文地址:IT屋 What is the loss of data in &#39;uintmax_t&#39; to &#39;size_t&#39; and &#39;unsigned int&#39; conversion?

官方微信

扫一扫关注IT屋

微信公众号搜索 “ IT屋 ” ,选择关注与百万开发者在一起


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-128907-1.html

    相关阅读
      发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

      热点图片
      拼命载入中...