Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
0f038e5f
Commit
0f038e5f
authored
May 05, 1991
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added (dummy) divmod and (functional) abs.
Fixed comments in number methods list
parent
75380b65
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
10 deletions
+37
-10
Objects/floatobject.c
Objects/floatobject.c
+37
-10
No files found.
Objects/floatobject.c
View file @
0f038e5f
...
...
@@ -197,6 +197,20 @@ float_rem(v, w)
return
newfloatobject
(
fmod
(
v
->
ob_fval
,
wx
));
}
static
object
*
float_divmod
(
v
,
w
)
floatobject
*
v
;
object
*
w
;
{
double
wx
;
if
(
!
is_floatobject
(
w
))
{
err_badarg
();
return
NULL
;
}
err_setstr
(
RuntimeError
,
"divmod() on float not implemented"
);
return
NULL
;
}
static
object
*
float_pow
(
v
,
w
)
floatobject
*
v
;
...
...
@@ -210,7 +224,7 @@ float_pow(v, w)
iv
=
v
->
ob_fval
;
iw
=
((
floatobject
*
)
w
)
->
ob_fval
;
if
(
iw
==
0
.
0
)
return
newfloatobject
(
1
.
0
);
/* x**0 is
always
1, even 0**0 */
return
newfloatobject
(
1
.
0
);
/* x**0 is 1, even 0**0 */
errno
=
0
;
ix
=
pow
(
iv
,
iw
);
if
(
errno
!=
0
)
{
...
...
@@ -232,18 +246,31 @@ static object *
float_pos
(
v
)
floatobject
*
v
;
{
return
newfloatobject
(
v
->
ob_fval
);
INCREF
(
v
);
return
(
object
*
)
v
;
}
static
object
*
float_abs
(
v
)
floatobject
*
v
;
{
if
(
v
->
ob_fval
<
0
)
return
float_neg
(
v
);
else
return
float_pos
(
v
);
}
static
number_methods
float_as_number
=
{
float_add
,
/*tp_add*/
float_sub
,
/*tp_subtract*/
float_mul
,
/*tp_multiply*/
float_div
,
/*tp_divide*/
float_rem
,
/*tp_remainder*/
float_pow
,
/*tp_power*/
float_neg
,
/*tp_negate*/
float_pos
,
/*tp_plus*/
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*/
};
typeobject
Floattype
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment