Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Boxiang Sun
Pyston
Commits
6a67f455
Commit
6a67f455
authored
Nov 16, 2014
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement FloorDivInt
parent
1f043e3d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
5 deletions
+20
-5
src/runtime/float.cpp
src/runtime/float.cpp
+20
-5
No files found.
src/runtime/float.cpp
View file @
6a67f455
...
...
@@ -153,14 +153,29 @@ extern "C" Box* floatRDiv(BoxedFloat* lhs, Box* rhs) {
}
}
extern
"C"
Box
*
floatFloorDivFloat
(
BoxedFloat
*
lhs
,
BoxedFloat
*
rhs
)
{
assert
(
lhs
->
cls
==
float_cls
);
assert
(
rhs
->
cls
==
float_cls
);
raiseDivZeroExcIfZero
(
rhs
->
d
);
return
boxFloat
(
floor
(
lhs
->
d
/
rhs
->
d
));
}
extern
"C"
Box
*
floatFloorDivInt
(
BoxedFloat
*
lhs
,
BoxedInt
*
rhs
)
{
assert
(
lhs
->
cls
==
float_cls
);
assert
(
rhs
->
cls
==
int_cls
);
raiseDivZeroExcIfZero
(
rhs
->
n
);
return
boxFloat
(
floor
(
lhs
->
d
/
rhs
->
n
));
}
extern
"C"
Box
*
floatFloorDiv
(
BoxedFloat
*
lhs
,
Box
*
rhs
)
{
assert
(
lhs
->
cls
==
float_cls
);
if
(
rhs
->
cls
!=
float_cls
)
{
if
(
rhs
->
cls
==
int_cls
)
{
return
floatFloorDivInt
(
lhs
,
static_cast
<
BoxedInt
*>
(
rhs
));
}
else
if
(
rhs
->
cls
==
float_cls
)
{
return
floatFloorDivFloat
(
lhs
,
static_cast
<
BoxedFloat
*>
(
rhs
));
}
else
{
return
NotImplemented
;
}
BoxedFloat
*
rhs_float
=
static_cast
<
BoxedFloat
*>
(
rhs
);
raiseDivZeroExcIfZero
(
rhs_float
->
d
);
return
boxFloat
(
floor
(
lhs
->
d
/
rhs_float
->
d
));
}
extern
"C"
Box
*
floatEqFloat
(
BoxedFloat
*
lhs
,
BoxedFloat
*
rhs
)
{
...
...
@@ -592,7 +607,7 @@ void setupFloat() {
_addFunc
(
"__div__"
,
BOXED_FLOAT
,
(
void
*
)
floatDivFloat
,
(
void
*
)
floatDivInt
,
(
void
*
)
floatDiv
);
_addFunc
(
"__rdiv__"
,
BOXED_FLOAT
,
(
void
*
)
floatRDivFloat
,
(
void
*
)
floatRDivInt
,
(
void
*
)
floatRDiv
);
float_cls
->
giveAttr
(
"__floordiv__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
floatFloorDiv
,
UNKNOWN
,
2
))
);
_addFunc
(
"__floordiv__"
,
BOXED_FLOAT
,
(
void
*
)
floatFloorDivFloat
,
(
void
*
)
floatFloorDivInt
,
(
void
*
)
floatFloorDiv
);
_addFunc
(
"__truediv__"
,
BOXED_FLOAT
,
(
void
*
)
floatDivFloat
,
(
void
*
)
floatDivInt
,
(
void
*
)
floatTruediv
);
_addFunc
(
"__eq__"
,
BOXED_BOOL
,
(
void
*
)
floatEqFloat
,
(
void
*
)
floatEqInt
,
(
void
*
)
floatEq
);
...
...
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