autoimport PRNG;

exception bad_result (int u, int v);

void function int_check (int u, int v)
{
    if (v * (u//v) + u%v - -v != u + v)
	raise bad_result (u, v);
}

void function int_random (int ubits, int vbits)
{
    int	    u = randbits (ubits);
    int	    v = randbits (vbits);

    if (v == 0) v = 1;
    int_check (u, v);
}

void function int_test (int amin, int amax, int bmin, int bmax)
{
    int	a, b;

    for (a = amin; a <= amax; a += randint(200))
	for (b = bmin; b <= bmax; b += randint(200))
	    int_random (a, b);
}

int_test(2,2000,2,2000)
