unsigned long long + int [英] unsigned long long + int

查看:122
本文介绍了unsigned long long + int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我添加unsigned long long和int时,在执行添加之前,每个

值会被提升为什么类型?结果表达式的

类型是什么?如果添加溢出

或下溢会发生什么?


谢谢,


-Peter

When I add an unsigned long long and an int, what type do each of the
values get promoted to before the addition is performed? What is the
type of the resulting expression? What occurs if the addition overflows
or underflows?

Thanks,

-Peter

推荐答案

" Peter Ammon" < PE ********* @ rocketmail.com>在消息中写道

news:cj ********** @ news.apple.com ...
"Peter Ammon" <pe*********@rocketmail.com> wrote in message
news:cj**********@news.apple.com...
当我添加一个unsigned long long和int,在执行添加之前,每个
值被提升为什么类型?


''unsigned long long''对象根本没有提升。

''int''对象被提升为''unsigned long long ''。

结果表达式的
类型是什么?


''unsigned long long''

如果加法溢出
或下溢会发生什么?
When I add an unsigned long long and an int, what type do each of the
values get promoted to before the addition is performed?
The ''unsigned long long'' object is not promoted at all.
The ''int'' object is promoted to ''unsigned long long''.
What is the
type of the resulting expression?
''unsigned long long''
What occurs if the addition overflows
or underflows?




未定义。


-Mike



Undefined.

-Mike




" Mike Wahler" < MK ****** @ mkwahler.net>在消息中写道

新闻:WI **************** @ newsread3.news.pas.earthli nk.net ...

"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:WI****************@newsread3.news.pas.earthli nk.net...
彼得·阿蒙 < PE ********* @ rocketmail.com>在消息中写道
新闻:cj ********** @ news.apple.com ...
"Peter Ammon" <pe*********@rocketmail.com> wrote in message
news:cj**********@news.apple.com...
当我添加一个unsigned long long和一个int时,是什么类型在执行添加之前,每个
值都会被提升吗?
When I add an unsigned long long and an int, what type do each of the
values get promoted to before the addition is performed?



unsigned long long对象根本不会被提升。
''int''对象被提升为''unsigned long long''。



The ''unsigned long long'' object is not promoted at all.
The ''int'' object is promoted to ''unsigned long long''.

结果表达式的
类型是什么?
What is the
type of the resulting expression?



''unsigned long long''



''unsigned long long''

如果加法溢出
或下溢会发生什么?
What occurs if the addition overflows
or underflows?



未定义。



Undefined.




对不起,这不对。溢出后,无符号整数

类型将''换行'为零。

有符号整数类型会发生未定义的行为。


-Mike



Sorry, this is not correct. Upon overflow, unsigned integer
types will ''wrap'' to zero. The undefined behavior occurs with
signed integer types.

-Mike


Mike Wahler写道:
Mike Wahler wrote:
" Peter Ammon" < PE ********* @ rocketmail.com>在消息中写道
新闻:cj ********** @ news.apple.com ...
"Peter Ammon" <pe*********@rocketmail.com> wrote in message
news:cj**********@news.apple.com...
当我添加一个unsigned long long和int,在执行添加之前,每个
值被提升为什么类型?
When I add an unsigned long long and an int, what type do each of the
values get promoted to before the addition is performed?



根本不提升unsigned long long对象。
''int''对象被提升为''unsigned long long''。


The ''unsigned long long'' object is not promoted at all.
The ''int'' object is promoted to ''unsigned long long''.




谢谢!这次促销是如何发生的?是否保证将模数转换为模数ULLONG_MAX + 1(我希望如此),或者它是一个实现

定义的东西?


[...]


-Peter


-

拉出分裂回复。



Thanks! How does this promotion occur? Is it guaranteed to convert the
value modulo ULLONG_MAX + 1 (like I hope), or is it an implementation
defined thing?

[...]

-Peter

--
Pull out a splinter to reply.


这篇关于unsigned long long + int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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