哪个C演员类型是C演员相当于

哪个C演员类型是C演员相当于,第1张

概述我猜C只是一个重新解释,并且位模式保持原样. 我试图理解当我将更宽的有符号值转换为更窄的有符号值时会发生什么.是保留符号,还是简单地将较窄宽度中的值解释为带符号值. 谢谢你的帮助. 编辑 – 这是针对C99编译的c代码.问题不在于c编译器将使用粗糙的旧样式转换,而是如果有什么定义C的作用. 如果你只关心C,你真的不需要询问C,但在你的例子中,C和C仍然做大部分相同的事情; C说这些完整的转换: I 我猜C只是一个重新解释,并且位模式保持原样.

我试图理解当我将更宽的有符号值转换为更窄的有符号值时会发生什么.是保留符号,还是简单地将较窄宽度中的值解释为带符号值.

谢谢你的帮助.

编辑 – 这是针对C99编译的c代码.问题不在于c编译器将使用粗糙的旧样式转换,而是如果有什么定义C的作用.

解决方法 如果你只关心C,你真的不需要询问C,但在你的例子中,C和C仍然做大部分相同的事情;

C说这些完整的转换:

If the destination type is signed,the value is unchanged if it can be represented in the destination type (and bit-fIEld wIDth); otherwise,the value is implementation-defined.

C99说这些积分转换:

Otherwise,the new type is signed and the value cannot be represented in it; either the
result is implementation-defined or an implementation-defined signal is raised.

如果可能的话,将较大的整数值转换为较小的有符号整数值将产生相同的值,否则给出实现定义(即,非可移植)行为.

§5.4/ 4州

The conversions performed by

a const_cast (5.2.11), a static_cast (5.2.9), a static_cast followed by a const_cast, a reinterpret_cast (5.2.10),or a reinterpret_cast followed by a const_cast,

can be performed using the cast notation of explicit type conversion.

[…]

If a conversion can be interpreted in more than one of the ways Listed above,the interpretation that
appears first in the List is used,even if a cast resulting from that interpretation is ill-formed.

定义C使其与C兼容;也就是说,C强制转换将在C中执行与在C中相同的 *** 作.这意味着C中的强制转换符号实际上根据之间的类型执行不同的 *** 作.

总结

以上是内存溢出为你收集整理的哪个C演员类型是C演员相当于全部内容,希望文章能够帮你解决哪个C演员类型是C演员相当于所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1219873.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-05
下一篇 2022-06-05

发表评论

登录后才能评论

评论列表(0条)

保存