# 2.11BSD#431 - /usr/src/new/PORT/B/src/bint/b1num.h

##### Macros

    Approximate       X
    Copy              X
    Denominator       X
    Digit             X
    EXT_RANGE         X
    Even              X
    Exact             X
    Expo              X
    Frac              X
    Freeze1           X
    Freeze2           X
    FreezeSmallInt    X
    Integral          X
    Lsd               X
    Modulo            X
    Msd               X
    Numerator         X
    Odd               X
    Rational          X
    Roundsize         X
    int_0             X
    int_1             X
    int_10            X
    int_2             X
    int_diff          X
    int_neg           X
    int_sum           X
    invlogtwo         X
    logBASE           X
    logten            X
    logtwo            X
    twologBASE        X

##### struct's

    integer           X
    real              X

##### typedef's

    digit             X
    integer           X
    real              X

       1: /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
       2:
       3: /*
       4:   $Header: b1num.h,v 1.4 85/08/22 16:41:53 timo Exp $
       5: */
       6:
       7: /************************************************************************/
       8: /* Full numeric package: private definitions                            */
       9: /*                                                                      */
      10: /* A number is modelled as one of zero, unbounded integer,              */
      11: /*        unbounded rational or approximate.                            */
      12: /*     Zero has a 'length' field of zero, and nothing else.             */
      13: /*     A length field of +n means the number is an n digit integer,     */
      14: /*        (with digits to some large base).                             */
      15: /*     A length of -1 means there follow two floating point numbers,    */
      16: /*        one the fraction (zero or .5 <= frac <= 1), one the exponent  */
      17: /*        with respect to base 2 (should be an integral value).         */
      18: /*        (This is so when EXT_RANGE is defined.  Otherwise, there is   */
      19: /*        only one field, frac, which is not normalized.  This saves    */
      20: /*        code and data space on e.g. the IBM PC, where the natural     */
      21: /*        range of double's is sufficient (~1E307).)                    */
      22: /*     A length of -2 means there follow two values, pointers to two    */
      23: /*        unbounded integers, ie a rational number.                     */
      24: /*     A length of -n, n>2, means it is a rational with a print width   */
      25: /*        of n-2.                                                       */
      26: /*                                                                      */
      27: /************************************************************************/
      28:
      29: /*************** Definitions exported for integers *****************/
      30:
      31: typedef int digit;
      32:
      33: typedef struct integer {
      34:     HEADER;
      35:     digit   dig[1];
      36: } *integer;
      37:
      38: #define FreezeSmallInt(v, vv) \
      39:     (IsSmallInt(v) && (Freeze1(v, vv), Freeze2(v, vv)))
      40: #define Freeze1(v, vv) ((vv).type= Num, (vv).refcnt= Maxrefcnt)
      41: #define Freeze2(v, vv) \
      42:     ((vv).len= (v) != 0, (vv).dig[0]= SmallIntVal(v), (v)= &(vv))
      43:
      44: integer int_gadd();
      45: integer int_canon();
      46: integer int_prod();
      47: integer int_quot();
      48: integer int_gcd();
      49: integer mk_int();
      50: integer int1mul();
      51: integer int_tento();
      52: integer int_half();
      53: integer int_mod();
      54: digit int_ldiv();
      55:
      56: #define int_0 ((integer) MkSmallInt(0))
      57: #define int_1 ((integer) MkSmallInt(1))
      58: #define int_2 ((integer) MkSmallInt(2))
      59: #define int_10 ((integer) MkSmallInt(10))
      60:
      61: #define int_sum(v, w) int_gadd(v, w, 1)
      62: #define int_diff(v, w) int_gadd(v, w, -1)
      63: #define int_neg(v) int_gadd(int_0, v, -1)
      64:
      65: #define Integral(v) (IsSmallInt(v) || Length(v)>=0)
      66: #define Modulo(a,b) (((a)%(b)+(b))%(b))
      67: #define Digit(v,n) ((v)->dig[n])
      68: #define Msd(v) (IsSmallInt(v) ? SmallIntVal(v) : Digit(v,Length(v)-1))
      69: #define Lsd(v) (IsSmallInt(v) ? SmallIntVal(v) : Digit(v,0))
      70:
      71: #define Odd(x) ((x)&1)
      72: #define Even(x) (!Odd(x))
      73:
      74: /* Provisional definitions */
      75:
      76: value copy();
      77: #define Copy(x) copy((value)(x))
      78:
      79: /***************** Definitions exported for rationals *****************/
      80:
      81: typedef struct {
      82:     HEADER;
      83:     integer num, den;
      84: } *rational;
      85:
      86:
      87: #define Numerator(a) ((a)->num)
      88: #define Denominator(a) ((a)->den)
      89: #define Rational(a) (!IsSmallInt(a) && Length(a)<-1)
      90: #define Roundsize(a) (-2-Length(a))
      91:
      92: rational mk_rat();
      93: rational rat_sum();
      94: rational rat_diff();
      95: rational rat_neg();
      96: rational rat_prod();
      97: rational rat_quot();
      98: rational rat_power();
      99:
     100: extern rational rat_zero;
     101: extern rational rat_half;
     102:
     103: value tento();
     104: value mk_exact();
     105:
     106: /***************** Definitions exported for approximate numbers *************/
     107:
     108: #ifdef vax
     109: #define EXT_RANGE
     110: #endif
     111:
     112: typedef struct real {
     113:     HEADER;
     114:     double  frac;
     115: #ifdef EXT_RANGE
     116:     double  expo;
     117: #endif EXT_RANGE
     118: } *real;
     119:
     120: #define Frac(v) ((v)->frac)
     121: #ifdef EXT_RANGE
     122: #define Expo(v) ((v)->expo)
     123: #else
     124: #define Expo(v) 0.0
     125: #endif
     126:
     127: #define Approximate(v) (!IsSmallInt(v) && Length(v)==-1)
     128: #define Exact(v) (!Approximate(v))
     129:
     130: extern real app_0;
     131:
     132: real mk_approx();
     133:
     134: real app_sum();
     135: real app_diff();
     136: real app_prod();
     137: real app_quot();
     138: real app_neg();
     139:
     140: real app_exp();
     141: real app_log();
     142: real app_power();
     143:
     144: value app_floor();
     145:
     146:
     147: /* Numeric constants. */
     148: /* (Source: Knuth, The Art of Computer Programming, Vol. 1, Appendix B-1.) */
     149:
     150: #define logtwo 0.6931471805599453094172321214581765680755
     151: #define invlogtwo 1.4426950408889634073599246810018921374266
     152: #define logten 2.3025850929940456840179914546843642076011
     153: #define logBASE (logten*tenlogBASE)
     154: #define twologBASE (logBASE*invlogtwo)

#### Defined struct's

integer defined in line 33; used 16 times

- in /usr/src/new/PORT/B/src/bint/b1nuG.c line 121(2)
- in /usr/src/new/PORT/B/src/bint/b1nuI.c line 139(2), 164(2), 190(2), 297(2)
- in /usr/src/new/PORT/B/src/bint/b1nuQ.c line 20(2), 47(2), 69(2)

real defined in line 112; used 4 times

- in /usr/src/new/PORT/B/src/bint/b1nuA.c line 28-31(4)

#### Defined typedef's

digit defined in line 31; used 30 times

- in line 54-35(2)
- in /usr/src/new/PORT/B/src/bint/b1fun.c line 281
- in /usr/src/new/PORT/B/src/bint/b1nuC.c line 210
- in /usr/src/new/PORT/B/src/bint/b1nuG.c line 26-27(3), 87
- in /usr/src/new/PORT/B/src/bint/b1nuI.c line 75, 87, 110-113(3), 154, 245(2), 276
- in /usr/src/new/PORT/B/src/bint/b1nuQ.c line 15-17(2), 43, 65-68(2), 112-121(3), 127, 217, 225
- in /usr/src/new/PORT/B/src/bint/b1val.c line 57, 159

integer defined in line 36; used 139 times

- in line 44-59(14), 83
- in /usr/src/new/PORT/B/src/bint/b1fun.c line 55-57(2), 64(2), 87(2), 97(2), 120, 142, 151-152(2), 179(2), 205-208(3), 214, 222, 229, 280, 378, 398, 418, 449(2)
- in /usr/src/new/PORT/B/src/bint/b1nuA.c line 236
- in /usr/src/new/PORT/B/src/bint/b1nuC.c line 18, 32, 120, 209, 227, 257
- in /usr/src/new/PORT/B/src/bint/b1nuG.c line 55-59(3), 86(2), 103, 111, 120(2), 130, 139-142(3), 159
- in /usr/src/new/PORT/B/src/bint/b1nuI.c line 61(2), 77, 84-94(3), 138-140(3), 149, 161-173(6), 187, 230-239(5), 247, 274-282(4), 294
- in /usr/src/new/PORT/B/src/bint/b1nuQ.c line 15-16(3), 24, 43-44(3), 51, 65-66(2), 97-98(2), 115, 126-129(2), 198, 209-219(8)
- in /usr/src/new/PORT/B/src/bint/b1nuR.c line 23, 32-34(2), 60, 90, 106, 122, 135, 170-171(2), 247
- in /usr/src/new/PORT/B/src/bint/b1num.c line 37, 61, 80, 121-125(3), 160-164(3), 174, 211, 264
- in /usr/src/new/PORT/B/src/bint/b1val.c line 138, 146

real defined in line 118; used 88 times

- in line 130-142(10)
- in /usr/src/new/PORT/B/src/bint/b1fun.c line 25, 75-77(5), 145, 156-157(2), 173, 200, 224, 247, 256-261(2), 284, 400(2), 516, 534, 547(2), 580(2), 589-590(3), 596-597(3), 612(3)
- in /usr/src/new/PORT/B/src/bint/b1nuA.c line 34, 40-46(3), 52-55(2), 67-71(4), 79-85(4), 94-105(7), 116-120(3), 137(2), 185-188(3), 194, 215, 234
- in /usr/src/new/PORT/B/src/bint/b1nuC.c line 69(2), 305-310(3)
- in /usr/src/new/PORT/B/src/bint/b1num.c line 183-188(4), 194(2), 233(2)

#### Defined macros

Approximate defined in line 127; used 10 times

- in line 128
- in /usr/src/new/PORT/B/src/bint/b1fun.c line 76-77(2), 156, 173, 284, 413, 516, 534
- in /usr/src/new/PORT/B/src/bint/b1nuC.c line 303

Copy defined in line 77; used 54 times

- in /usr/src/new/PORT/B/src/bint/b1fun.c line 56-58(2), 64, 76-77(2), 124, 159, 175, 209-214(2), 283, 307, 325, 413, 422, 451, 485-487(2), 504, 518, 570
- in /usr/src/new/PORT/B/src/bint/b1nuA.c line 46, 52, 71, 85, 105, 120, 194
- in /usr/src/new/PORT/B/src/bint/b1nuG.c line 141-142(2), 159
- in /usr/src/new/PORT/B/src/bint/b1nuI.c line 167-168(2)
- in /usr/src/new/PORT/B/src/bint/b1nuQ.c line 98, 126
- in /usr/src/new/PORT/B/src/bint/b1nuR.c line 22, 42, 48-49(2), 57, 63, 71-72(2), 140, 157-161(2), 178, 185-194(6)
- in /usr/src/new/PORT/B/src/bint/b1num.c line 125

Denominator defined in line 88; used 22 times

- in /usr/src/new/PORT/B/src/bint/b1fun.c line 63, 203, 213, 232, 288, 423, 504
- in /usr/src/new/PORT/B/src/bint/b1nuC.c line 317, 327
- in /usr/src/new/PORT/B/src/bint/b1nuR.c line 58, 69-72(2), 87, 181-185(2), 193, 237, 274-278(2)
- in /usr/src/new/PORT/B/src/bint/b1num.c line 106, 124, 272

Digit defined in line 67; used 75 times

- in line 68-69(2)
- in /usr/src/new/PORT/B/src/bint/b1fun.c line 431, 440, 455
- in /usr/src/new/PORT/B/src/bint/b1nuC.c line 44, 57, 235, 246
- in /usr/src/new/PORT/B/src/bint/b1nuG.c line 77-78(2), 95-104(4)
- in /usr/src/new/PORT/B/src/bint/b1nuI.c line 66, 75-81(3), 87-91(2), 151-154(5), 176-179(4), 202-203(2), 213(2), 220(2), 249-251(2), 285, 304-310(4)
- in /usr/src/new/PORT/B/src/bint/b1nuQ.c line 27-35(4), 53-54(2), 94-97(3), 103, 113, 134-146(8), 153-156(3), 162(2), 173-180(5)
- in /usr/src/new/PORT/B/src/bint/b1num.c line 45, 264
- in /usr/src/new/PORT/B/src/bint/b1val.c line 147

EXT_RANGE defined in line 109; used 23 times

- in line 115, 121
- in /usr/src/new/PORT/B/src/bint/b1nuA.c line 27-30(2), 42, 51, 57, 68, 74, 80, 89, 138, 168, 187, 196, 210, 217-222(2), 235, 249
- in /usr/src/new/PORT/B/src/bint/b1nuC.c line 63, 121
- in /usr/src/new/PORT/B/src/bint/b1val.c line 59

Even defined in line 72; used 8 times

- in /usr/src/new/PORT/B/src/bint/b1fun.c line 233, 245
- in /usr/src/new/PORT/B/src/bint/b1nuG.c line 32-34(3), 43, 113-114(2)

Exact defined in line 128; used 7 times

- in /usr/src/new/PORT/B/src/bint/b1fun.c line 50(2), 201, 221, 395, 480, 497

Expo defined in line 124; used 38 times

- in /usr/src/new/PORT/B/src/bint/b1fun.c line 548, 581, 613-614(2)
- in /usr/src/new/PORT/B/src/bint/b1nuA.c line 58, 70-73(7), 83-88(7), 95-99(3), 107(2), 117, 140, 189, 206, 224(2), 238-243(4)
- in /usr/src/new/PORT/B/src/bint/b1nuC.c line 70(2), 310
- in /usr/src/new/PORT/B/src/bint/b1num.c line 233

Frac defined in line 120; used 45 times

- in /usr/src/new/PORT/B/src/bint/b1fun.c line 156, 173, 225(2), 257-262(3), 400(2), 516, 534, 548, 581, 613-614(2)
- in /usr/src/new/PORT/B/src/bint/b1nuA.c line 56, 72-75(4), 87-107(10), 117, 140, 169, 186, 205, 211, 221(2), 240-242(2), 250
- in /usr/src/new/PORT/B/src/bint/b1nuC.c line 70, 305-310(2)
- in /usr/src/new/PORT/B/src/bint/b1num.c line 233

Freeze1 defined in line 40; used 1 times

- in line 39

Freeze2 defined in line 41; used 1 times

- in line 39

FreezeSmallInt defined in line 38; used 14 times

- in /usr/src/new/PORT/B/src/bint/b1nuG.c line 133-134(2)
- in /usr/src/new/PORT/B/src/bint/b1nuI.c line 143-144(2), 170-171(2), 198-199(2), 301-302(2)
- in /usr/src/new/PORT/B/src/bint/b1nuQ.c line 22, 49, 86-87(2)

Integral defined in line 65; used 24 times

- in /usr/src/new/PORT/B/src/bint/b1fun.c line 47(2), 55-57(2), 141, 150, 178(2), 201-208(3), 228, 283, 307, 325, 356, 376, 448, 485, 502
- in /usr/src/new/PORT/B/src/bint/b1nuA.c line 247
- in /usr/src/new/PORT/B/src/bint/b1nuC.c line 120
- in /usr/src/new/PORT/B/src/bint/b1num.c line 106, 257

Lsd defined in line 69; used 4 times

- in /usr/src/new/PORT/B/src/bint/b1fun.c line 233, 245
- in /usr/src/new/PORT/B/src/bint/b1nuG.c line 114
- in /usr/src/new/PORT/B/src/bint/b1nuR.c line 201

Modulo defined in line 66; used 5 times

- in /usr/src/new/PORT/B/src/bint/b1nuI.c line 245
- in /usr/src/new/PORT/B/src/bint/b1nuQ.c line 30-34(2), 157, 181

Msd defined in line 68; used 21 times

- in /usr/src/new/PORT/B/src/bint/b1fun.c line 151-154(2), 241, 398
- in /usr/src/new/PORT/B/src/bint/b1nuC.c line 52
- in /usr/src/new/PORT/B/src/bint/b1nuG.c line 61, 123(2), 171
- in /usr/src/new/PORT/B/src/bint/b1nuI.c line 299
- in /usr/src/new/PORT/B/src/bint/b1nuQ.c line 74, 80, 223, 230
- in /usr/src/new/PORT/B/src/bint/b1nuR.c line 44, 62, 175-180(2), 257-258(2)
- in /usr/src/new/PORT/B/src/bint/b1num.c line 44

Numerator defined in line 87; used 31 times

- in /usr/src/new/PORT/B/src/bint/b1fun.c line 64, 154, 172, 205, 214, 235, 288, 397, 418, 487, 515
- in /usr/src/new/PORT/B/src/bint/b1nuC.c line 319
- in /usr/src/new/PORT/B/src/bint/b1nuR.c line 57, 68-71(2), 86, 138, 157, 176-192(6), 236, 273-277(2)
- in /usr/src/new/PORT/B/src/bint/b1num.c line 60, 79, 125, 271

Odd defined in line 71; used 2 times

- in line 72
- in /usr/src/new/PORT/B/src/bint/b1nuR.c line 201

Rational defined in line 89; used 14 times

- in /usr/src/new/PORT/B/src/bint/b1fun.c line 143, 153, 172, 203, 374, 396, 416, 515
- in /usr/src/new/PORT/B/src/bint/b1nuC.c line 160, 317
- in /usr/src/new/PORT/B/src/bint/b1num.c line 60, 79, 106, 270

Roundsize defined in line 90; used 12 times

- in /usr/src/new/PORT/B/src/bint/b1fun.c line 63
- in /usr/src/new/PORT/B/src/bint/b1nuC.c line 160-161(2), 318
- in /usr/src/new/PORT/B/src/bint/b1nuR.c line 17-19(8)

int_0 defined in line 56; used 34 times

- in line 63
- in /usr/src/new/PORT/B/src/bint/b1fun.c line 122, 171-172(2), 237, 290, 398, 421, 514-515(2)
- in /usr/src/new/PORT/B/src/bint/b1nuG.c line 65, 183
- in /usr/src/new/PORT/B/src/bint/b1nuI.c line 71, 166(3), 300
- in /usr/src/new/PORT/B/src/bint/b1nuQ.c line 71, 95, 220
- in /usr/src/new/PORT/B/src/bint/b1nuR.c line 36, 42, 55, 138, 157, 173-176(2), 190, 200, 253-254(4), 273

int_1 defined in line 57; used 37 times

- in /usr/src/new/PORT/B/src/bint/b1fun.c line 55-57(2), 63, 203-213(3), 230, 291, 378, 520
- in /usr/src/new/PORT/B/src/bint/b1nuC.c line 213, 288, 317
- in /usr/src/new/PORT/B/src/bint/b1nuG.c line 126(3)
- in /usr/src/new/PORT/B/src/bint/b1nuI.c line 167-168(2)
- in /usr/src/new/PORT/B/src/bint/b1nuR.c line 55-58(2), 67, 173(2), 197-212(5), 218-223(2), 274-277(2)
- in /usr/src/new/PORT/B/src/bint/b1num.c line 106, 124, 164, 174, 212

int_10 defined in line 59; used 2 times

- in /usr/src/new/PORT/B/src/bint/b1nuC.c line 84-89(2)

int_2 defined in line 58; used 4 times

- in /usr/src/new/PORT/B/src/bint/b1fun.c line 532-537(2)
- in /usr/src/new/PORT/B/src/bint/b1nuA.c line 244
- in /usr/src/new/PORT/B/src/bint/b1nuR.c line 278

int_diff defined in line 62; used 5 times

- in /usr/src/new/PORT/B/src/bint/b1fun.c line 98, 291
- in /usr/src/new/PORT/B/src/bint/b1nuG.c line 181
- in /usr/src/new/PORT/B/src/bint/b1nuQ.c line 231
- in /usr/src/new/PORT/B/src/bint/b1nuR.c line 111

int_neg defined in line 63; used 16 times

- in /usr/src/new/PORT/B/src/bint/b1fun.c line 142, 152
- in /usr/src/new/PORT/B/src/bint/b1nuC.c line 46
- in /usr/src/new/PORT/B/src/bint/b1nuG.c line 161, 177
- in /usr/src/new/PORT/B/src/bint/b1nuI.c line 256
- in /usr/src/new/PORT/B/src/bint/b1nuQ.c line 77, 83, 199
- in /usr/src/new/PORT/B/src/bint/b1nuR.c line 45-46(2), 62, 160, 181-182(2), 188

int_sum defined in line 61; used 3 times

- in /usr/src/new/PORT/B/src/bint/b1fun.c line 88
- in /usr/src/new/PORT/B/src/bint/b1nuQ.c line 230
- in /usr/src/new/PORT/B/src/bint/b1nuR.c line 95

invlogtwo defined in line 151; used 1 times

- in line 154

logBASE defined in line 153; used 1 times

- in line 154

logten defined in line 152; used 1 times

- in line 153

logtwo defined in line 150; used 4 times

- in /usr/src/new/PORT/B/src/bint/b1fun.c line 466
- in /usr/src/new/PORT/B/src/bint/b1nuA.c line 122, 142, 205

twologBASE defined in line 154; used 1 times

- in /usr/src/new/PORT/B/src/bint/b1fun.c line 464

#### Usage of this include

b1num.h used 9 times

- in /usr/src/new/PORT/B/src/bint/b1fun.c line 14
- in /usr/src/new/PORT/B/src/bint/b1nuA.c line 12
- in /usr/src/new/PORT/B/src/bint/b1nuC.c line 13
- in /usr/src/new/PORT/B/src/bint/b1nuG.c line 10
- in /usr/src/new/PORT/B/src/bint/b1nuI.c line 11
- in /usr/src/new/PORT/B/src/bint/b1nuQ.c line 10
- in /usr/src/new/PORT/B/src/bint/b1nuR.c line 12
- in /usr/src/new/PORT/B/src/bint/b1num.c line 12
- in /usr/src/new/PORT/B/src/bint/b1val.c line 20

Last modified: 1985-08-27 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 891 |