This discussion is archived
3 Replies Latest reply: Dec 1, 2006 11:29 AM by 796440 RSS

Adding two possitive numbers results a negative????

807607 Newbie
Currently Being Moderated
Hello everybody i posted that in an other subforum but i guess it was the wrong place. I have a strange problem that it's racking my brain! i have the following code
for (int i=0;i<ascii.length;i++){
int randNum=rand.nextInt(100000000); 
buffer=randNum*256+ascii[i];
}
(ascii[i] is an array of four integers that picture an ascii characters).

Normaly that would result a buffer full of positive numbers.In my case thats not always true. Many times i get as a result a negative number even if the other two numbers that i add are positive. What's wrong here?? Thanks in advance!