开发者

How to add the 256 value only to negative numbers?Result i get from modorg is the same as modulus [closed]

Closed. This question needs de开发者_C百科tails or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 9 years ago.

Improve this question
//arrays modulus and modrog

byte[] modulus ={-30, 0 , 25, 70,-25,-3,-2};  
byte[] modorg=new byte[7];

//the loop that counts the elements

for (int j = 0; j < modulus.length; j++)
{
    if (modulus[j] < 0)
    {
        modorg[j] = (byte) ((int)modulus[j] + 256);
    }
    else
    {
        modorg[j]=modorg[j];
    }
}


Adding 256 to a byte is like adding 360 to a degree :) You will get the same value. You probably want to add 128?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜