-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbigguy.h
97 lines (75 loc) · 3.23 KB
/
bigguy.h
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/****************************************************************************/
/* */
/* This file is part of CONCORDE */
/* */
/* (c) Copyright 1995--1999 by David Applegate, Robert Bixby, */
/* Vasek Chvatal, and William Cook */
/* */
/* Permission is granted for academic research use. For other uses, */
/* contact the authors for licensing options. */
/* */
/* Use at your own risk. We make no guarantees about the */
/* correctness or usefulness of this code. */
/* */
/****************************************************************************/
#ifndef __BIGGUY_H
#define __BIGGUY_H
#define BIT_32_UMAX 4294967295
#define BIT_32_SMAX 2147483647
#define BIT_32_UMAXF 4294967295.0
#define BIT_32_SMAXF 2147483647.0
#include "util.h"
#undef CC_BIGGUY_LONG
#undef CC_BIGGUY_LONGLONG
#ifdef CC_BIGGUY_LONGLONG
typedef long long CCbigguy;
#define CC_BIGGUY_BUILTIN
#endif
#ifdef CC_BIGGUY_LONG
typedef long CCbigguy;
#define CC_BIGGUY_BUILTIN
#endif
#ifdef CC_BIGGUY_BUILTIN
#define CCbigguy_FRACBITS 32
#define CCbigguy_DUALSCALE (((CCbigguy) 1) << CCbigguy_FRACBITS)
#define CCbigguy_FRACPART(x) ((x) & (CCbigguy_DUALSCALE-1))
#define CCbigguy_MAXBIGGUY (((((CCbigguy) 1) << 62) - 1) + \
(((CCbigguy) 1) << 62))
#define CCbigguy_MINBIGGUY (-CCbigguy_MAXBIGGUY)
#define CCbigguy_bigguytod(x) (((double) (x)) / ((double) CCbigguy_DUALSCALE))
#define CCbigguy_itobigguy(d) ((CCbigguy) ((d) * (double) CCbigguy_DUALSCALE))
#define CCbigguy_ceil(x) (CCbigguy_FRACPART(x) ? \
((x) + (CCbigguy_DUALSCALE - CCbigguy_FRACPART(x))) : (x))
#define CCbigguy_cmp(x,y) (((x) < (y)) ? -1 : ((x) > (y)) ? 1 : 0)
#define CCbigguy_ZERO ((CCbigguy) 0)
#define CCbigguy_ONE ((CCbigguy) CCbigguy_DUALSCALE)
#define CCbigguy_addmult(x,y,m) ((*x) += (y)*(m))
#define CCbigguy_dtobigguy(d) ((CCbigguy) ((d) * (double) CCbigguy_DUALSCALE))
#else /* CC_BIGGUY_BUILTIN */
typedef struct CCbigguy {
unsigned int ihi;
unsigned int ilo;
unsigned int fhi;
unsigned int flo;
} CCbigguy;
extern const CCbigguy CCbigguy_MINBIGGUY;
extern const CCbigguy CCbigguy_MAXBIGGUY;
extern const CCbigguy CCbigguy_ZERO;
extern const CCbigguy CCbigguy_ONE;
void
CCbigguy_addmult (CCbigguy *x, CCbigguy y, int m);
int
CCbigguy_cmp (CCbigguy x, CCbigguy y);
double
CCbigguy_bigguytod (CCbigguy x);
CCbigguy
CCbigguy_itobigguy (int d),
CCbigguy_dtobigguy (double d),
CCbigguy_ceil (CCbigguy x);
#endif /* CC_BIGGUY_BUILTIN */
#define CCbigguy_add(x,y) (CCbigguy_addmult(x,y,1))
#define CCbigguy_sub(x,y) (CCbigguy_addmult(x,y,-1))
int
CCbigguy_swrite (CC_SFILE *f, CCbigguy x),
CCbigguy_sread (CC_SFILE *f, CCbigguy *x);
#endif /* __BIGGUY_H */