2 * qmath - extended precision rational arithmetic primitive routines
4 * Copyright (C) 1999-2007 David I. Bell and Ernest Bowen
6 * Primary author: David I. Bell
8 * Calc is open software; you can redistribute it and/or modify it under
9 * the terms of the version 2.1 of the GNU Lesser General Public License
10 * as published by the Free Software Foundation.
12 * Calc is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
15 * Public License for more details.
17 * A copy of version 2.1 of the GNU Lesser General Public License is
18 * distributed with calc under the filename COPYING-LGPL. You should have
19 * received a copy with calc; if not, write to Free Software Foundation, Inc.
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * @(#) $Revision: 30.2 $
23 * @(#) $Id: qmath.c,v 30.2 2013/08/11 08:41:38 chongo Exp $
24 * @(#) $Source: /usr/local/src/bin/calc/RCS/qmath.c,v $
26 * Under source code control: 1990/02/15 01:48:21
27 * File existed as early as: before 1990
29 * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
38 NUMBER _qzero_
= { { _zeroval_
, 1, 0 }, { _oneval_
, 1, 0 }, 1, NULL
};
39 NUMBER _qone_
= { { _oneval_
, 1, 0 }, { _oneval_
, 1, 0 }, 1, NULL
};
40 NUMBER _qtwo_
= { { _twoval_
, 1, 0 }, { _oneval_
, 1, 0 }, 1, NULL
};
41 NUMBER _qthree_
= { { _threeval_
, 1, 0 }, { _oneval_
, 1, 0 }, 1, NULL
};
42 NUMBER _qfour_
= { { _fourval_
, 1, 0 }, { _oneval_
, 1, 0 }, 1, NULL
};
43 NUMBER _qten_
= { { _tenval_
, 1, 0 }, { _oneval_
, 1, 0 }, 1, NULL
};
44 NUMBER _qnegone_
= { { _oneval_
, 1, 1 }, { _oneval_
, 1, 0 }, 1, NULL
};
45 NUMBER _qonehalf_
= { { _oneval_
, 1, 0 }, { _twoval_
, 1, 0 }, 1, NULL
};
46 NUMBER _qneghalf_
= { { _oneval_
, 1, 1 }, { _twoval_
, 1, 0 }, 1, NULL
};
47 NUMBER _qonesqbase_
= { { _oneval_
, 1, 0 }, { _sqbaseval_
, 2, 0 }, 1, NULL
};
49 NUMBER
* initnumbs
[INITCONSTCOUNT
] = {&_qzero_
, &_qone_
, &_qtwo_
, &_qthree_
,
50 &_qfour_
, &_qten_
, &_qnegone_
, &_qonehalf_
, &_qneghalf_
};
54 * Create another copy of a number.
63 r
->num
.sign
= q
->num
.sign
;
64 if (!zisunit(q
->num
)) {
65 r
->num
.len
= q
->num
.len
;
66 r
->num
.v
= alloc(r
->num
.len
);
67 zcopyval(q
->num
, r
->num
);
69 if (!zisunit(q
->den
)) {
70 r
->den
.len
= q
->den
.len
;
71 r
->den
.v
= alloc(r
->den
.len
);
72 zcopyval(q
->den
, r
->den
);
79 * Convert a number to a normal integer.
90 zquo(q
->num
, q
->den
, &res
, 0);
98 * Convert a normal integer into a number.
106 if ((i
>= -1) && (i
<= 10)) {
108 case 0: q
= &_qzero_
; break;
109 case 1: q
= &_qone_
; break;
110 case 2: q
= &_qtwo_
; break;
111 case 10: q
= &_qten_
; break;
112 case -1: q
= &_qnegone_
; break;
125 * Convert a number to a normal unsigned integer.
136 zquo(q
->num
, q
->den
, &res
, 0);
144 * Convert a number to a normal signed integer.
155 zquo(q
->num
, q
->den
, &res
, 0);
163 * Convert a normal unsigned integer into a number.
173 case 0: q
= &_qzero_
; break;
174 case 1: q
= &_qone_
; break;
175 case 2: q
= &_qtwo_
; break;
176 case 10: q
= &_qten_
; break;
189 * Convert a normal signed integer into a number.
199 case 0: q
= &_qzero_
; break;
200 case 1: q
= &_qone_
; break;
201 case 2: q
= &_qtwo_
; break;
202 case 10: q
= &_qten_
; break;
215 * Create a number from the given FULL numerator and denominator.
216 * q = uutoq(inum, iden);
219 uutoq(FULL inum
, FULL iden
)
226 math_error("Division by zero");
230 return qlink(&_qzero_
);
232 d
= uugcd(inum
, iden
);
247 * Create a number from the given integral numerator and denominator.
248 * q = iitoq(inum, iden);
251 iitoq(long inum
, long iden
)
258 math_error("Division by zero");
262 return qlink(&_qzero_
);
272 d
= iigcd(inum
, iden
);
276 return itoq(sign
? -inum
: inum
);
287 * Add two numbers to each other.
288 * q3 = qqadd(q1, q2);
291 qqadd(NUMBER
*q1
, NUMBER
*q2
)
294 ZVALUE t1
, t2
, temp
, d1
, d2
, vpd1
, upd1
;
302 * If either number is an integer, then the result is easy.
304 if (qisint(q1
) && qisint(q2
)) {
305 zadd(q1
->num
, q2
->num
, &r
->num
);
309 zmul(q1
->den
, q2
->num
, &temp
);
310 zadd(q1
->num
, temp
, &r
->num
);
312 zcopy(q1
->den
, &r
->den
);
316 zmul(q2
->den
, q1
->num
, &temp
);
317 zadd(q2
->num
, temp
, &r
->num
);
319 zcopy(q2
->den
, &r
->den
);
323 * Both arguments are true fractions, so we need more work.
324 * If the denominators are relatively prime, then the answer is the
325 * straightforward cross product result with no need for reduction.
327 zgcd(q1
->den
, q2
->den
, &d1
);
330 zmul(q1
->num
, q2
->den
, &t1
);
331 zmul(q1
->den
, q2
->num
, &t2
);
332 zadd(t1
, t2
, &r
->num
);
335 zmul(q1
->den
, q2
->den
, &r
->den
);
339 * The calculation is now more complicated.
340 * See Knuth Vol 2 for details.
342 zquo(q2
->den
, d1
, &vpd1
, 0);
343 zquo(q1
->den
, d1
, &upd1
, 0);
344 zmul(q1
->num
, vpd1
, &t1
);
345 zmul(q2
->num
, upd1
, &t2
);
355 zmul(upd1
, q2
->den
, &r
->den
);
359 zquo(temp
, d2
, &r
->num
, 0);
361 zquo(q2
->den
, d2
, &temp
, 0);
363 zmul(temp
, upd1
, &r
->den
);
371 * Subtract one number from another.
375 qsub(NUMBER
*q1
, NUMBER
*q2
)
380 return qlink(&_qzero_
);
383 if (qisint(q1
) && qisint(q2
)) {
385 zsub(q1
->num
, q2
->num
, &r
->num
);
398 * Increment a number by one.
407 zadd(q
->num
, _one_
, &r
->num
);
410 zadd(q
->num
, q
->den
, &r
->num
);
411 zcopy(q
->den
, &r
->den
);
417 * Decrement a number by one.
426 zsub(q
->num
, _one_
, &r
->num
);
429 zsub(q
->num
, q
->den
, &r
->num
);
430 zcopy(q
->den
, &r
->den
);
436 * Add a normal small integer value to an arbitrary number.
439 qaddi(NUMBER
*q1
, long n
)
441 NUMBER addnum
; /* temporary number */
442 HALF addval
[2]; /* value of small number */
443 BOOL neg
; /* TRUE if number is neg */
444 #if LONG_BITS > BASEB
457 addnum
.num
.v
= addval
;
462 addval
[0] = (HALF
) n
;
463 #if LONG_BITS > BASEB
464 nf
= (((FULL
) n
) >> BASEB
);
466 addval
[1] = (HALF
) nf
;
473 return qsub(q1
, &addnum
);
475 return qqadd(q1
, &addnum
);
480 * Multiply two numbers.
484 qmul(NUMBER
*q1
, NUMBER
*q2
)
486 NUMBER
*r
; /* returned value */
487 ZVALUE n1
, n2
, d1
, d2
; /* numerators and denominators */
490 if (qiszero(q1
) || qiszero(q2
))
491 return qlink(&_qzero_
);
496 if (qisint(q1
) && qisint(q2
)) { /* easy results if integers */
498 zmul(q1
->num
, q2
->num
, &r
->num
);
505 if (ziszero(d1
) || ziszero(d2
)) {
506 math_error("Division by zero");
509 if (ziszero(n1
) || ziszero(n2
))
510 return qlink(&_qzero_
);
511 if (!zisunit(n1
) && !zisunit(d2
)) { /* possibly reduce */
514 zequo(q1
->num
, tmp
, &n1
);
515 zequo(q2
->den
, tmp
, &d2
);
519 if (!zisunit(n2
) && !zisunit(d1
)) { /* again possibly reduce */
522 zequo(q2
->num
, tmp
, &n2
);
523 zequo(q1
->den
, tmp
, &d1
);
528 zmul(n1
, n2
, &r
->num
);
529 zmul(d1
, d2
, &r
->den
);
530 if (q1
->num
.v
!= n1
.v
)
532 if (q1
->den
.v
!= d1
.v
)
534 if (q2
->num
.v
!= n2
.v
)
536 if (q2
->den
.v
!= d2
.v
)
543 * Multiply a number by a small integer.
547 qmuli(NUMBER
*q
, long n
)
550 long d
; /* gcd of multiplier and denominator */
553 if ((n
== 0) || qiszero(q
))
554 return qlink(&_qzero_
);
559 zmuli(q
->num
, n
, &r
->num
);
567 d
= zmodi(q
->den
, n
);
569 zmuli(q
->num
, (n
* sign
) / d
, &r
->num
);
570 (void) zdivi(q
->den
, d
, &r
->den
);
576 * Divide two numbers (as fractions).
577 * q3 = qqdiv(q1, q2);
580 qqdiv(NUMBER
*q1
, NUMBER
*q2
)
585 math_error("Division by zero");
588 if ((q1
== q2
) || !qcmp(q1
, q2
))
589 return qlink(&_qone_
);
594 temp
.num
.sign
= temp
.den
.sign
;
597 return qmul(q1
, &temp
);
602 * Divide a number by a small integer.
606 qdivi(NUMBER
*q
, long n
)
609 long d
; /* gcd of divisor and numerator */
613 math_error("Division by zero");
616 if ((n
== 1) || qiszero(q
))
624 d
= zmodi(q
->num
, n
);
626 (void) zdivi(q
->num
, d
* sign
, &r
->num
);
627 zmuli(q
->den
, n
/ d
, &r
->den
);
633 * Return the integer quotient of a pair of numbers
634 * If q1/q2 is an integer qquo(q1, q2) returns this integer
635 * If q2 is zero, zero is returned
636 * In other cases whether rounding is down, up, towards zero, etc.
637 * is determined by rnd.
640 qquo(NUMBER
*q1
, NUMBER
*q2
, long rnd
)
642 ZVALUE tmp
, tmp1
, tmp2
;
645 if (qiszero(q1
) || qiszero(q2
))
646 return qlink(&_qzero_
);
647 if (qisint(q1
) && qisint(q2
)) {
648 zquo(q1
->num
, q2
->num
, &tmp
, rnd
);
650 zmul(q1
->num
, q2
->den
, &tmp1
);
651 zmul(q2
->num
, q1
->den
, &tmp2
);
652 zquo(tmp1
, tmp2
, &tmp
, rnd
);
658 return qlink(&_qzero_
);
667 * Return the absolute value of a number.
675 if (q
->num
.sign
== 0)
678 if (!zisunit(q
->num
))
679 zcopy(q
->num
, &r
->num
);
680 if (!zisunit(q
->den
))
681 zcopy(q
->den
, &r
->den
);
697 return qlink(&_qzero_
);
699 if (!zisunit(q
->num
))
700 zcopy(q
->num
, &r
->num
);
701 if (!zisunit(q
->den
))
702 zcopy(q
->den
, &r
->den
);
703 r
->num
.sign
= !q
->num
.sign
;
709 * Return the sign of a number (-1, 0 or 1)
715 return qlink(&_qzero_
);
717 return qlink(&_qnegone_
);
718 return qlink(&_qone_
);
732 r
= (qisneg(q
) ? &_qnegone_
: &_qone_
);
736 math_error("Division by zero");
740 if (!zisunit(q
->num
))
741 zcopy(q
->num
, &r
->den
);
742 if (!zisunit(q
->den
))
743 zcopy(q
->den
, &r
->num
);
744 r
->num
.sign
= q
->num
.sign
;
751 * Return just the numerator of a number.
761 if (zisunit(q
->num
)) {
762 r
= (qisneg(q
) ? &_qnegone_
: &_qone_
);
766 zcopy(q
->num
, &r
->num
);
772 * Return just the denominator of a number.
781 return qlink(&_qone_
);
783 zcopy(q
->den
, &r
->num
);
789 * Return the fractional part of a number.
798 return qlink(&_qzero_
);
799 if ((q
->num
.len
< q
->den
.len
) || ((q
->num
.len
== q
->den
.len
) &&
800 (q
->num
.v
[q
->num
.len
- 1] < q
->den
.v
[q
->num
.len
- 1])))
803 zmod(q
->num
, q
->den
, &r
->num
, 2);
804 zcopy(q
->den
, &r
->den
);
810 * Return the integral part of a number.
820 if ((q
->num
.len
< q
->den
.len
) || ((q
->num
.len
== q
->den
.len
) &&
821 (q
->num
.v
[q
->num
.len
- 1] < q
->den
.v
[q
->num
.len
- 1])))
822 return qlink(&_qzero_
);
824 zquo(q
->num
, q
->den
, &r
->num
, 2);
830 * Compute the square of a number.
838 return qlink(&_qzero_
);
840 return qlink(&_qone_
);
845 zsquare(num
, &q
->num
);
847 zsquare(zden
, &q
->den
);
853 * Shift an integer by a given number of bits. This multiplies the number
854 * by the appropriate power of two. Positive numbers shift left, negative
855 * ones shift right. Low bits are truncated when shifting right.
858 qshift(NUMBER
*q
, long n
)
863 math_error("Shift of non-integer");
866 if (qiszero(q
) || (n
== 0))
868 if (n
<= -(q
->num
.len
* BASEB
))
869 return qlink(&_qzero_
);
871 zshift(q
->num
, n
, &r
->num
);
877 * Scale a number by a power of two, as in:
879 * This is similar to shifting, except that fractions work.
882 qscale(NUMBER
*q
, long pow
)
884 long numshift
, denshift
, tmp
;
887 if (qiszero(q
) || (pow
== 0))
889 numshift
= zisodd(q
->num
) ? 0 : zlowbit(q
->num
);
890 denshift
= zisodd(q
->den
) ? 0 : zlowbit(q
->den
);
896 numshift
= (pow
- tmp
);
903 denshift
= (pow
- tmp
);
907 zshift(q
->num
, numshift
, &r
->num
);
909 zcopy(q
->num
, &r
->num
);
911 zshift(q
->den
, denshift
, &r
->den
);
913 zcopy(q
->den
, &r
->den
);
919 * Return the minimum of two numbers.
922 qmin(NUMBER
*q1
, NUMBER
*q2
)
926 if (qrel(q1
, q2
) > 0)
933 * Return the maximum of two numbers.
936 qmax(NUMBER
*q1
, NUMBER
*q2
)
940 if (qrel(q1
, q2
) < 0)
947 * Perform the bitwise OR of two integers.
950 qor(NUMBER
*q1
, NUMBER
*q2
)
953 NUMBER
*q1tmp
, *q2tmp
, *q
;
955 if (qisfrac(q1
) || qisfrac(q2
)) {
956 math_error("Non-integers for bitwise or");
959 if (qcmp(q1
,q2
) == 0 || qiszero(q2
))
967 q
= qand(q1tmp
,q2tmp
);
974 q
= qandnot(q1tmp
, q2
);
982 q
= qandnot(q2tmp
, q1
);
989 zor(q1
->num
, q2
->num
, &r
->num
);
995 * Perform the bitwise AND of two integers.
998 qand(NUMBER
*q1
, NUMBER
*q2
)
1001 NUMBER
*q1tmp
, *q2tmp
, *q
;
1004 if (qisfrac(q1
) || qisfrac(q2
)) {
1005 math_error("Non-integers for bitwise and");
1008 if (qcmp(q1
, q2
) == 0)
1010 if (qiszero(q1
) || qiszero(q2
))
1011 return qlink(&_qzero_
);
1016 q
= qor(q1tmp
, q2tmp
);
1023 r
= qandnot(q2
, q1tmp
);
1029 r
= qandnot(q1
, q2tmp
);
1033 zand(q1
->num
, q2
->num
, &res
);
1036 return qlink(&_qzero_
);
1045 * Perform the bitwise XOR of two integers.
1048 qxor(NUMBER
*q1
, NUMBER
*q2
)
1051 NUMBER
*q1tmp
, *q2tmp
, *q
;
1054 if (qisfrac(q1
) || qisfrac(q2
)) {
1055 math_error("Non-integers for bitwise xor");
1058 if (qcmp(q1
,q2
) == 0)
1059 return qlink(&_qzero_
);
1068 r
= qxor(q1tmp
, q2tmp
);
1073 q
= qxor(q1tmp
, q2
);
1081 q
= qxor(q1
, q2tmp
);
1087 zxor(q1
->num
, q2
->num
, &res
);
1090 return qlink(&_qzero_
);
1099 * Perform the bitwise ANDNOT of two integers.
1102 qandnot(NUMBER
*q1
, NUMBER
*q2
)
1105 NUMBER
*q1tmp
, *q2tmp
, *q
;
1107 if (qisfrac(q1
) || qisfrac(q2
)) {
1108 math_error("Non-integers for bitwise xor");
1111 if (qcmp(q1
,q2
) == 0 || qiszero(q1
))
1112 return qlink(&_qzero_
);
1119 r
= qandnot(q2tmp
, q1tmp
);
1132 r
= qand(q1
, q2tmp
);
1137 zandnot(q1
->num
, q2
->num
, &r
->num
);
1142 * Return the bitwise "complement" of a number. This is - q -1 if q is an
1143 * integer, - q otherwise.
1152 return qlink(&_qnegone_
);
1154 return qlink(&_qzero_
);
1165 * Return the number whose binary representation only has the specified
1166 * bit set (counting from zero). This thus produces a given power of two.
1174 return qlink(&_qone_
);
1177 zbitvalue(n
, &r
->num
);
1179 zbitvalue(-n
, &r
->den
);
1192 return qlink(&_qone_
);
1195 ztenpow(n
, &r
->num
);
1197 ztenpow(-n
, &r
->den
);
1203 * Return the precision of a number (usually for examining an epsilon value).
1204 * The precision of a number e less than 1 is the positive
1205 * integer p for which e = 2^-p * f, where 1 <= f < 2.
1206 * Numbers greater than or equal to one have a precision of zero.
1207 * For example, the precision of e is 6 if 1/64 <= e < 1/32.
1210 qprecision(NUMBER
*q
)
1214 if (qiszero(q
) || qisneg(q
)) {
1215 math_error("Non-positive number for precision");
1219 return (r
< 0 ? 0 : r
);
1224 * Determine whether or not one number exactly divides another one.
1225 * Returns TRUE if the first number is an integer multiple of the second one.
1228 qdivides(NUMBER
*q1
, NUMBER
*q2
)
1232 if (qisint(q1
) && qisint(q2
)) {
1235 return zdivides(q1
->num
, q2
->num
);
1237 return zdivides(q1
->num
, q2
->num
) && zdivides(q2
->den
, q1
->den
);
1242 * Compare two numbers and return an integer indicating their relative size.
1246 qrel(NUMBER
*q1
, NUMBER
*q2
)
1251 int z1f
= 0, z2f
= 0;
1255 sign
= q2
->num
.sign
- q1
->num
.sign
;
1259 return !qiszero(q1
);
1263 * Make a quick comparison by calculating the number of words
1264 * resulting as if we multiplied through by the denominators,
1265 * and then comparing the word counts.
1270 wc1
= q1
->num
.len
+ q2
->den
.len
;
1271 wc2
= q2
->num
.len
+ q1
->den
.len
;
1277 * Quick check failed, must actually do the full comparison.
1279 if (zisunit(q2
->den
)) {
1281 } else if (zisone(q1
->num
)) {
1285 zmul(q1
->num
, q2
->den
, &z1
);
1287 if (zisunit(q1
->den
)) {
1289 } else if (zisone(q2
->num
)) {
1293 zmul(q2
->num
, q1
->den
, &z2
);
1295 sign
= zrel(z1
, z2
);
1305 * Compare two numbers to see if they are equal.
1306 * This differs from qrel in that the numbers are not ordered.
1307 * Returns TRUE if they differ.
1310 qcmp(NUMBER
*q1
, NUMBER
*q2
)
1314 if ((q1
->num
.sign
!= q2
->num
.sign
) || (q1
->num
.len
!= q2
->num
.len
) ||
1315 (q2
->den
.len
!= q2
->den
.len
) || (*q1
->num
.v
!= *q2
->num
.v
) ||
1316 (*q1
->den
.v
!= *q2
->den
.v
))
1318 if (zcmp(q1
->num
, q2
->num
))
1322 return zcmp(q1
->den
, q2
->den
);
1327 * Compare a number against a normal small integer.
1328 * Returns 1, 0, or -1, according to whether the first number is greater,
1329 * equal, or less than the second number.
1330 * res = qreli(q, n);
1333 qreli(NUMBER
*q
, long n
)
1339 return ((n
> 0) ? -1 : (n
< 0));
1342 return (q
->num
.sign
? -1 : 0);
1344 if (q
->num
.sign
!= (n
< 0))
1345 return ((n
< 0) ? 1 : -1);
1350 zmul(q
->den
, z1
, &z2
);
1355 res
= zrel(q
->num
, z1
);
1362 * Compare a number against a small integer to see if they are equal.
1363 * Returns TRUE if they differ.
1366 qcmpi(NUMBER
*q
, long n
)
1369 #if LONG_BITS > BASEB
1374 if (qisfrac(q
) || (q
->num
.sign
!= (n
< 0)))
1378 if (((HALF
)(n
)) != q
->num
.v
[0])
1380 #if LONG_BITS > BASEB
1381 nf
= ((FULL
) n
) >> BASEB
;
1382 return ((nf
!= 0 || len
> 1) && (len
!= 2 || nf
!= q
->num
.v
[1]));
1390 * Number node allocation routines
1393 #define NNALLOC 1000
1396 STATIC NUMBER
*freeNum
= NULL
;
1397 STATIC NUMBER
**firstNums
= NULL
;
1398 STATIC
long blockcount
= 0;
1407 if (freeNum
== NULL
) {
1408 freeNum
= (NUMBER
*) malloc(sizeof (NUMBER
) * NNALLOC
);
1409 if (freeNum
== NULL
) {
1410 math_error("Not enough memory");
1413 freeNum
[NNALLOC
- 1].next
= NULL
;
1414 freeNum
[NNALLOC
- 1].links
= 0;
1417 * We prevent the temp pointer from walking behind freeNum
1418 * by stopping one short of the end and running the loop one
1421 * We would stop the loop with just temp >= freeNum, but
1422 * doing this helps make code checkers such as insure happy.
1424 for (temp
= freeNum
+ NNALLOC
- 2; temp
> freeNum
; --temp
) {
1425 temp
->next
= temp
+ 1;
1428 /* run the loop manually one last time */
1429 temp
->next
= temp
+ 1;
1433 if (firstNums
== NULL
) {
1434 newfn
= (NUMBER
**) malloc(blockcount
* sizeof(NUMBER
*));
1437 realloc(firstNums
, blockcount
* sizeof(NUMBER
*));
1439 if (newfn
== NULL
) {
1440 math_error("Cannot allocate new number block");
1444 firstNums
[blockcount
- 1] = freeNum
;
1447 freeNum
= temp
->next
;
1459 math_error("Calling qfreenum with null argument!!!");
1462 if (q
->links
!= 0) {
1463 math_error("Calling qfreenum with nozero links!!!");
1479 printf("Index Links Digits Value\n");
1480 printf("----- ----- ------ -----\n");
1482 for (i
= 0, k
= 0; i
< INITCONSTCOUNT
; i
++) {
1485 printf("%6ld %4ld ", k
++, vp
->links
);
1490 for (i
= 0; i
< blockcount
; i
++) {
1492 for (j
= 0; j
< NNALLOC
; j
++, k
++, vp
++) {
1493 if (vp
->links
> 0) {
1495 printf("%6ld %4ld ", k
, vp
->links
);
1501 printf("\nNumber: %ld\n", count
);