* Copyright (c) 1982 Regents of the University of California
* @(#)asnumber.h 4.3 2/14/82
union Il_int
{ /* long word */
union Iq_int
{ /* quad word */
union Ff_float numFf_float
;
union Fd_float numFd_float
;
char num_tag
; /* the key field: TYPB..TYPUNPACKED */
char num_sign
; /* the sign */
short num_exponent
; /* the unexcessed exp */
typedef struct as_number Bignum
;
extern Bignum Znumber
; /* one all zero'ed out */
#define num_uchar num_num.numIq_int.Iq_uchar
#define num_uint num_num.numIq_int.Iq_ulong
#define num_ulong num_num.numIq_int.Iq_ulong
#define num_ushort num_num.numIq_int.Iq_ushort
* The following definitions must all be consistent.
* They define the granularity of working on longs and quad
* words. Currently, the granularity is as large as it can be: 32 bits
#define CH_N 2 /* number of pieces */
#define CH_BITS 32 /* number of bits per piece */
#define CH_FIELD(x) ((x).num_num.numIq_int.Iq_ulong)
typedef u_int
*chptr
; /* basic data type */
#define SIGNBIT 0x80000000
#define HOC (CH_N - 1) /* high order chunk */
#define MAXINT_1 ((unsigned)(1<<(CH_BITS - 1)))
#define MAXINT_10 ((unsigned)((MAXINT_1/(unsigned)10)))
#define MAXINT_5 ((unsigned)((MAXINT_1/(unsigned)5)))
* These values were computed using dc, so are exact.
* Only MAXINT_10 and MAXINT_5 are used in the programs.
#define MAXINT_1 2147483648
#define MAXINT_10 214748364
#define MAXINT_5 429496729
Bignum
as_atoi(); /* converts string to integer */
Bignum
as_atof(); /* converts string to float */
* Definitions for overflows.
#define OVF_ADDV (1<<0) /* integer: adding two vectors overflowed */
#define OVF_LSHIFT (1<<1) /* integer: left shifting a vector lost bits */
#define OVF_POSOVF (1<<2) /* integer: positive number overflowed */
#define OVF_MAXINT (1<<3) /* integer: the number was the maxint + 1*/
#define OVF_F (1<<4) /* float: F overflow */
#define OVF_D (1<<5) /* float: D overflow */
#define OVF_OVERFLOW (1<<9) /* overflow in conversion */
#define OVF_UNDERFLOW (1<<10) /* underflow in conversion */
#define ONES(n) ((1 << (n)) - 1)
#define assert(x, str) if (!(x)) panic("%s%s\n", "x", str)