小编use*_*302的帖子

十六进制加法和减法

到目前为止我有这个代码.当我添加两个负整数时,答案是正面而不是负面.我该如何解决?我认为0x80000000是整数的最小可能值

#include <iostream>
#include <string>

using namespace std;

int main(void)
{
unsigned int maxInt = 0x7FFFFFFF;
int num1 = 7;
signed int minInt = 0x80000000;
int num2 = -21;
float num3 = 1;
float i;

cout<<"The value of the first variable is: "<<maxInt<<endl;
cout<<"The value of the second variable is: "<< num1<<endl;
cout<<"Addition of the two numbers: "<< maxInt + num1 <<endl;
cout<<endl;

cout<<"The value of the first variable is: "<<minInt<<endl;
cout<<"The value of the second variable is "<<num2<<endl;
cout<<"Addition …
Run Code Online (Sandbox Code Playgroud)

c++ hex

2
推荐指数
1
解决办法
2001
查看次数

标签 统计

c++ ×1

hex ×1