File: inttest.5c

package info (click to toggle)
nickle 2.68-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,336 kB
  • ctags: 3,288
  • sloc: ansic: 31,198; yacc: 1,860; lex: 858; sh: 830; makefile: 229
file content (29 lines) | stat: -rw-r--r-- 560 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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)