Bump version to 0.9.1.
[python/dscho.git] / Include / longintrepr.h
blob1e78d05e5d136d821765dc8b25dbd97e638141db
1 #ifndef Py_LONGINTREPR_H
2 #define Py_LONGINTREPR_H
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
7 /***********************************************************
8 Copyright (c) 2000, BeOpen.com.
9 Copyright (c) 1995-2000, Corporation for National Research Initiatives.
10 Copyright (c) 1990-1995, Stichting Mathematisch Centrum.
11 All rights reserved.
13 See the file "Misc/COPYRIGHT" for information on usage and
14 redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
15 ******************************************************************/
17 /* This is published for the benefit of "friend" marshal.c only. */
19 /* Parameters of the long integer representation.
20 These shouldn't have to be changed as C should guarantee that a short
21 contains at least 16 bits, but it's made changeable anyway.
22 Note: 'digit' should be able to hold 2*MASK+1, and 'twodigits'
23 should be able to hold the intermediate results in 'mul'
24 (at most MASK << SHIFT).
25 Also, x_sub assumes that 'digit' is an unsigned type, and overflow
26 is handled by taking the result mod 2**N for some N > SHIFT.
27 And, at some places it is assumed that MASK fits in an int, as well. */
29 typedef unsigned short digit;
30 typedef unsigned int wdigit; /* digit widened to parameter size */
31 #define BASE_TWODIGITS_TYPE long
32 typedef unsigned BASE_TWODIGITS_TYPE twodigits;
33 typedef BASE_TWODIGITS_TYPE stwodigits; /* signed variant of twodigits */
35 #define SHIFT 15
36 #define BASE ((digit)1 << SHIFT)
37 #define MASK ((int)(BASE - 1))
39 /* Long integer representation.
40 The absolute value of a number is equal to
41 SUM(for i=0 through abs(ob_size)-1) ob_digit[i] * 2**(SHIFT*i)
42 Negative numbers are represented with ob_size < 0;
43 zero is represented by ob_size == 0.
44 In a normalized number, ob_digit[abs(ob_size)-1] (the most significant
45 digit) is never zero. Also, in all cases, for all valid i,
46 0 <= ob_digit[i] <= MASK.
47 The allocation function takes care of allocating extra memory
48 so that ob_digit[0] ... ob_digit[abs(ob_size)-1] are actually available. */
50 struct _longobject {
51 PyObject_HEAD
52 int ob_size;
53 digit ob_digit[1];
56 DL_IMPORT(PyLongObject *) _PyLong_New(int);
58 #ifdef __cplusplus
60 #endif
61 #endif /* !Py_LONGINTREPR_H */