|
||||
File indexing completed on 2025-01-30 10:18:03
0001 #ifndef Py_CPYTHON_LONGOBJECT_H 0002 # error "this header file must not be included directly" 0003 #endif 0004 0005 PyAPI_FUNC(int) _PyLong_AsInt(PyObject *); 0006 0007 PyAPI_FUNC(int) _PyLong_UnsignedShort_Converter(PyObject *, void *); 0008 PyAPI_FUNC(int) _PyLong_UnsignedInt_Converter(PyObject *, void *); 0009 PyAPI_FUNC(int) _PyLong_UnsignedLong_Converter(PyObject *, void *); 0010 PyAPI_FUNC(int) _PyLong_UnsignedLongLong_Converter(PyObject *, void *); 0011 PyAPI_FUNC(int) _PyLong_Size_t_Converter(PyObject *, void *); 0012 0013 /* _PyLong_Frexp returns a double x and an exponent e such that the 0014 true value is approximately equal to x * 2**e. e is >= 0. x is 0015 0.0 if and only if the input is 0 (in which case, e and x are both 0016 zeroes); otherwise, 0.5 <= abs(x) < 1.0. On overflow, which is 0017 possible if the number of bits doesn't fit into a Py_ssize_t, sets 0018 OverflowError and returns -1.0 for x, 0 for e. */ 0019 PyAPI_FUNC(double) _PyLong_Frexp(PyLongObject *a, Py_ssize_t *e); 0020 0021 PyAPI_FUNC(PyObject *) PyLong_FromUnicodeObject(PyObject *u, int base); 0022 PyAPI_FUNC(PyObject *) _PyLong_FromBytes(const char *, Py_ssize_t, int); 0023 0024 /* _PyLong_Sign. Return 0 if v is 0, -1 if v < 0, +1 if v > 0. 0025 v must not be NULL, and must be a normalized long. 0026 There are no error cases. 0027 */ 0028 PyAPI_FUNC(int) _PyLong_Sign(PyObject *v); 0029 0030 /* _PyLong_NumBits. Return the number of bits needed to represent the 0031 absolute value of a long. For example, this returns 1 for 1 and -1, 2 0032 for 2 and -2, and 2 for 3 and -3. It returns 0 for 0. 0033 v must not be NULL, and must be a normalized long. 0034 (size_t)-1 is returned and OverflowError set if the true result doesn't 0035 fit in a size_t. 0036 */ 0037 PyAPI_FUNC(size_t) _PyLong_NumBits(PyObject *v); 0038 0039 /* _PyLong_DivmodNear. Given integers a and b, compute the nearest 0040 integer q to the exact quotient a / b, rounding to the nearest even integer 0041 in the case of a tie. Return (q, r), where r = a - q*b. The remainder r 0042 will satisfy abs(r) <= abs(b)/2, with equality possible only if q is 0043 even. 0044 */ 0045 PyAPI_FUNC(PyObject *) _PyLong_DivmodNear(PyObject *, PyObject *); 0046 0047 /* _PyLong_FromByteArray: View the n unsigned bytes as a binary integer in 0048 base 256, and return a Python int with the same numeric value. 0049 If n is 0, the integer is 0. Else: 0050 If little_endian is 1/true, bytes[n-1] is the MSB and bytes[0] the LSB; 0051 else (little_endian is 0/false) bytes[0] is the MSB and bytes[n-1] the 0052 LSB. 0053 If is_signed is 0/false, view the bytes as a non-negative integer. 0054 If is_signed is 1/true, view the bytes as a 2's-complement integer, 0055 non-negative if bit 0x80 of the MSB is clear, negative if set. 0056 Error returns: 0057 + Return NULL with the appropriate exception set if there's not 0058 enough memory to create the Python int. 0059 */ 0060 PyAPI_FUNC(PyObject *) _PyLong_FromByteArray( 0061 const unsigned char* bytes, size_t n, 0062 int little_endian, int is_signed); 0063 0064 /* _PyLong_AsByteArray: Convert the least-significant 8*n bits of long 0065 v to a base-256 integer, stored in array bytes. Normally return 0, 0066 return -1 on error. 0067 If little_endian is 1/true, store the MSB at bytes[n-1] and the LSB at 0068 bytes[0]; else (little_endian is 0/false) store the MSB at bytes[0] and 0069 the LSB at bytes[n-1]. 0070 If is_signed is 0/false, it's an error if v < 0; else (v >= 0) n bytes 0071 are filled and there's nothing special about bit 0x80 of the MSB. 0072 If is_signed is 1/true, bytes is filled with the 2's-complement 0073 representation of v's value. Bit 0x80 of the MSB is the sign bit. 0074 Error returns (-1): 0075 + is_signed is 0 and v < 0. TypeError is set in this case, and bytes 0076 isn't altered. 0077 + n isn't big enough to hold the full mathematical value of v. For 0078 example, if is_signed is 0 and there are more digits in the v than 0079 fit in n; or if is_signed is 1, v < 0, and n is just 1 bit shy of 0080 being large enough to hold a sign bit. OverflowError is set in this 0081 case, but bytes holds the least-significant n bytes of the true value. 0082 */ 0083 PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v, 0084 unsigned char* bytes, size_t n, 0085 int little_endian, int is_signed); 0086 0087 /* _PyLong_Format: Convert the long to a string object with given base, 0088 appending a base prefix of 0[box] if base is 2, 8 or 16. */ 0089 PyAPI_FUNC(PyObject *) _PyLong_Format(PyObject *obj, int base); 0090 0091 /* For use by the gcd function in mathmodule.c */ 0092 PyAPI_FUNC(PyObject *) _PyLong_GCD(PyObject *, PyObject *); 0093 0094 PyAPI_FUNC(PyObject *) _PyLong_Rshift(PyObject *, size_t); 0095 PyAPI_FUNC(PyObject *) _PyLong_Lshift(PyObject *, size_t); 0096 0097 0098 PyAPI_FUNC(int) PyUnstable_Long_IsCompact(const PyLongObject* op); 0099 PyAPI_FUNC(Py_ssize_t) PyUnstable_Long_CompactValue(const PyLongObject* op); 0100
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |