What is the answer to this strange problem:

What is the answer to this strange problem:

I wrote the following random generator, the a and z parameters form the range of random pick.

Code:

`public static int random(int a, int z) {`

int zz = z + a;

int rand = (int)(Math.random()*(zz-1)) + a;

System.out.println("random a " + a + " z " + z + " result " + rand);

return rand;

}

When calling the method from the same class everything works fine (the number output is a random pick between 1-10.

Code:

` public static void main (String args[]) { `

new fmEdit();

for (int i = 0; i < 200; i++)

random(1, 10);

}

But when calling this method from a different class e.g.

vel=ct.random(startgetal,80,100);

(in that class there are a large number of random calls, see bottom part)

the console print shows strange results why?

random a 79 z 394 result 156

random a 1 z 4 result 3

random a 1 z 0 result 1 ??????

random a 80 z 100 result 87

random a 1 z 2 result 2

random a 1 z 0 result 1 ?????

random a 80 z 100 result 110 !!!!!!!!!!!!!

random a 3 z 4 result 6

random a 0 z 127 result 34

random a 50 z 80 result 51

random a 10 z 60 result 53

random a 0 z 127 result 114

random a 50 z 80 result 81 !!!!!!!!!!!!!!!!

random a 10 z 60 result 49

random a 0 z 127 result 68

random a 50 z 80 result 144 !!!!!!!!!!!!

random a 10 z 60 result 26

random a 0 z 127 result 74

random a 50 z 80 result 108