对照 [英] comparison

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

问题描述

我想写一些像

status_bit =(unsigned)(i - j)> 31


作为

if(i< j){

{

status_bit = 1;

}否则{

status_bit = 0;

}


这实际上适用于大多数情况,但两个值都失败

i = 0x80000000

j = 0x7fffffff


我想要一个上面的线性代码,即没有跳转,所以

1.什么可能是问题?

2.可能是什么解决方案?

I want to write something like
status_bit = (unsigned)(i - j) >31

as an equivalent code for
if(i < j){
{
status_bit = 1;
}else{
status_bit = 0;
}

This actually works for most of the cases but fails for two values
i = 0x80000000
j = 0x7fffffff

I want a linear code for the above i.e. without jumps, so
1. what could be the issue?
2. what could be the solution?

推荐答案

10月21日,3:10 pm,ndu ... @ gmail.com写道:
On Oct 21, 3:10 pm, ndu...@gmail.com wrote:

我想写类似

status_bit =(unsigned)(i - j)> 31


作为
的等价代码
I want to write something like
status_bit = (unsigned)(i - j) >31

as an equivalent code for



签署int i;

signed int j;

signed int i;
signed int j;


if(i< j){

{

status_bit = 1;


}否则{

status_bit = 0;

}


这实际上适用于大多数但两个值都失败

i = 0x80000000

j = 0x7fffffff


我想要一个上面的线性代码,即没有跳转,所以

1.可能是什么问题?

2.可能是什么解决方案?
if(i < j){
{
status_bit = 1;

}else{
status_bit = 0;
}

This actually works for most of the cases but fails for two values
i = 0x80000000
j = 0x7fffffff

I want a linear code for the above i.e. without jumps, so
1. what could be the issue?
2. what could be the solution?



nd****@gmail.com 写道:

我想写类似

status_bit =(unsigned)(i - j)> 31 <


作为

的等价代码if(i< j){

{

status_bit = 1;

}否则{

status_bit = 0;

}
I want to write something like
status_bit = (unsigned)(i - j) >31

as an equivalent code for
if(i < j){
{
status_bit = 1;
}else{
status_bit = 0;
}



尝试简单的

status_bit =(i< j);

Try the simple
status_bit = (i < j);


这实际上适用于大多数情况但是两个值都失败了

i = 0x80000000

j = 0x7fffffff


我想要一个上面的线性代码,即没有跳转,所以

1.可能是什么问题?

2.可能是什么解决方案?
This actually works for most of the cases but fails for two values
i = 0x80000000
j = 0x7fffffff

I want a linear code for the above i.e. without jumps, so
1. what could be the issue?
2. what could be the solution?



是否有理由避免明显的

status_bit =(i< j);


Is there a reason for avoiding the obvious
status_bit = (i < j);
?


" Martin Ambuhl" < ma ***** @earthlink.netaécritdansle message de news:
5o ************ @ mid.individual.net ...
"Martin Ambuhl" <ma*****@earthlink.neta écrit dans le message de news:
5o************@mid.individual.net...
nd **** @ gmail.com 写道:

>我想写类似
的内容status_bit =(unsigned)(i - j)> 31

作为
的等效代码if(i< j){
{
status_bit = 1 ;
}否则{
status_bit = 0;
}
>I want to write something like
status_bit = (unsigned)(i - j) >31

as an equivalent code for
if(i < j){
{
status_bit = 1;
}else{
status_bit = 0;
}



尝试简单

status_bit = (i< j);


Try the simple
status_bit = (i < j);


>这实际上适用于大多数情况但是两个值都失败
i = 0x80000000
j = 0x7fffffff

我想要一个上面的线性代码,即没有跳跃,所以
1。可能是什么问题?
2。可能是什么解决方案?
>This actually works for most of the cases but fails for two values
i = 0x80000000
j = 0x7fffffff

I want a linear code for the above i.e. without jumps, so
1. what could be the issue?
2. what could be the solution?



是否有理由避免明显的

status_bit =(i< j);


Is there a reason for avoiding the obvious
status_bit = (i < j);



换句话说:如果有办法在没有测试和跳转的情况下计算这个,那么编译器应该知道



-

Chqrlie。

In other words: if there is a way to compute this without tests and jumps,
the compiler should know.

--
Chqrlie.


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

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