mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
Merge alpha100 branch back to main trunk
This commit is contained in:
parent
2979b01ff8
commit
b6775db241
176 changed files with 5302 additions and 3668 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/***********************************************************
|
||||
Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
|
||||
Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
|
||||
Amsterdam, The Netherlands.
|
||||
|
||||
All Rights Reserved
|
||||
|
|
@ -47,7 +47,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#define CHECK(x) /* Don't know how to check */
|
||||
#endif
|
||||
|
||||
#ifndef THINK_C
|
||||
#ifndef macintosh
|
||||
extern double fmod PROTO((double, double));
|
||||
extern double pow PROTO((double, double));
|
||||
#endif
|
||||
|
|
@ -77,12 +77,31 @@ double
|
|||
getfloatvalue(op)
|
||||
object *op;
|
||||
{
|
||||
if (!is_floatobject(op)) {
|
||||
number_methods *nb;
|
||||
floatobject *fo;
|
||||
double val;
|
||||
|
||||
if (op && is_floatobject(op))
|
||||
return GETFLOATVALUE((floatobject*) op);
|
||||
|
||||
if (op == NULL || (nb = op->ob_type->tp_as_number) == NULL ||
|
||||
nb->nb_float == NULL) {
|
||||
err_badarg();
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
return ((floatobject *)op) -> ob_fval;
|
||||
|
||||
fo = (floatobject*) (*nb->nb_float) (op);
|
||||
if (fo == NULL)
|
||||
return -1;
|
||||
if (!is_floatobject(fo)) {
|
||||
err_setstr(TypeError, "nb_float should return float object");
|
||||
return -1;
|
||||
}
|
||||
|
||||
val = GETFLOATVALUE(fo);
|
||||
DECREF(fo);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
/* Methods */
|
||||
|
|
@ -156,7 +175,17 @@ float_hash(v)
|
|||
/* This is designed so that Python numbers with the same
|
||||
value hash to the same value, otherwise comparisons
|
||||
of mapping keys will turn out weird */
|
||||
|
||||
#ifdef MPW /* MPW C modf expects pointer to extended as second argument */
|
||||
{
|
||||
extended e;
|
||||
fractpart = modf(v->ob_fval, &e);
|
||||
intpart = e;
|
||||
}
|
||||
#else
|
||||
fractpart = modf(v->ob_fval, &intpart);
|
||||
#endif
|
||||
|
||||
if (fractpart == 0.0) {
|
||||
if (intpart > 0x7fffffffL || -intpart > 0x7fffffffL) {
|
||||
/* Convert to long int and use its hash... */
|
||||
|
|
@ -372,27 +401,27 @@ float_float(v)
|
|||
|
||||
|
||||
static number_methods float_as_number = {
|
||||
float_add, /*nb_add*/
|
||||
float_sub, /*nb_subtract*/
|
||||
float_mul, /*nb_multiply*/
|
||||
float_div, /*nb_divide*/
|
||||
float_rem, /*nb_remainder*/
|
||||
float_divmod, /*nb_divmod*/
|
||||
float_pow, /*nb_power*/
|
||||
float_neg, /*nb_negative*/
|
||||
float_pos, /*nb_positive*/
|
||||
float_abs, /*nb_absolute*/
|
||||
float_nonzero, /*nb_nonzero*/
|
||||
(binaryfunc)float_add, /*nb_add*/
|
||||
(binaryfunc)float_sub, /*nb_subtract*/
|
||||
(binaryfunc)float_mul, /*nb_multiply*/
|
||||
(binaryfunc)float_div, /*nb_divide*/
|
||||
(binaryfunc)float_rem, /*nb_remainder*/
|
||||
(binaryfunc)float_divmod, /*nb_divmod*/
|
||||
(binaryfunc)float_pow, /*nb_power*/
|
||||
(unaryfunc)float_neg, /*nb_negative*/
|
||||
(unaryfunc)float_pos, /*nb_positive*/
|
||||
(unaryfunc)float_abs, /*nb_absolute*/
|
||||
(inquiry)float_nonzero, /*nb_nonzero*/
|
||||
0, /*nb_invert*/
|
||||
0, /*nb_lshift*/
|
||||
0, /*nb_rshift*/
|
||||
0, /*nb_and*/
|
||||
0, /*nb_xor*/
|
||||
0, /*nb_or*/
|
||||
float_coerce, /*nb_coerce*/
|
||||
float_int, /*nb_int*/
|
||||
float_long, /*nb_long*/
|
||||
float_float, /*nb_float*/
|
||||
(coercion)float_coerce, /*nb_coerce*/
|
||||
(unaryfunc)float_int, /*nb_int*/
|
||||
(unaryfunc)float_long, /*nb_long*/
|
||||
(unaryfunc)float_float, /*nb_float*/
|
||||
0, /*nb_oct*/
|
||||
0, /*nb_hex*/
|
||||
};
|
||||
|
|
@ -403,14 +432,14 @@ typeobject Floattype = {
|
|||
"float",
|
||||
sizeof(floatobject),
|
||||
0,
|
||||
float_dealloc, /*tp_dealloc*/
|
||||
float_print, /*tp_print*/
|
||||
(destructor)float_dealloc, /*tp_dealloc*/
|
||||
(printfunc)float_print, /*tp_print*/
|
||||
0, /*tp_getattr*/
|
||||
0, /*tp_setattr*/
|
||||
float_compare, /*tp_compare*/
|
||||
float_repr, /*tp_repr*/
|
||||
(cmpfunc)float_compare, /*tp_compare*/
|
||||
(reprfunc)float_repr, /*tp_repr*/
|
||||
&float_as_number, /*tp_as_number*/
|
||||
0, /*tp_as_sequence*/
|
||||
0, /*tp_as_mapping*/
|
||||
float_hash, /*tp_hash */
|
||||
(hashfunc)float_hash, /*tp_hash*/
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue