Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
28b719dd
Commit
28b719dd
authored
Sep 27, 2008
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement mod for floats.
parent
b0a706e6
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
16 deletions
+18
-16
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+11
-6
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+0
-4
tests/errors/e_modop.pyx
tests/errors/e_modop.pyx
+0
-6
tests/run/fmod.pyx
tests/run/fmod.pyx
+7
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
28b719dd
...
...
@@ -3414,22 +3414,27 @@ class FloorDivNode(NumBinopNode):
self
.
operand2
.
result
())
class
ModNode
(
Int
BinopNode
):
class
ModNode
(
Num
BinopNode
):
# '%' operator.
def
is_py_operation
(
self
):
return
(
self
.
operand1
.
type
.
is_string
or
self
.
operand2
.
type
.
is_string
or
Int
BinopNode
.
is_py_operation
(
self
))
or
Num
BinopNode
.
is_py_operation
(
self
))
def
calculate_result_code
(
self
):
if
self
.
operand1
.
type
.
is_float
or
self
.
operand2
.
type
.
is_float
:
return
"fmod(%s, %s)"
%
(
self
.
operand1
.
result
(),
self
.
operand2
.
result
())
else
:
return
"(%s %% %s)"
%
(
self
.
operand1
.
result
(),
self
.
operand2
.
result
())
class
PowNode
(
NumBinopNode
):
# '**' operator.
def
analyse_types
(
self
,
env
):
env
.
pow_function_used
=
1
NumBinopNode
.
analyse_types
(
self
,
env
)
def
compute_c_result_type
(
self
,
type1
,
type2
):
if
self
.
c_types_okay
(
type1
,
type2
):
return
PyrexTypes
.
c_double_type
...
...
Cython/Compiler/Symtab.py
View file @
28b719dd
...
...
@@ -167,7 +167,6 @@ class Scope:
# temp_counter integer Counter for naming temp vars
# cname_to_entry {string : Entry} Temp cname to entry mapping
# int_to_entry {int : Entry} Temp cname to entry mapping
# pow_function_used boolean The C pow() function is used
# return_type PyrexType or None Return type of function owning scope
# is_py_class_scope boolean Is a Python class scope
# is_c_class_scope boolean Is an extension type scope
...
...
@@ -221,7 +220,6 @@ class Scope:
#self.pending_temp_entries = [] # TEMPORARY
self.temp_counter = 1
self.cname_to_entry = {}
self.pow_function_used = 0
self.string_to_entry = {}
self.identifier_to_entry = {}
self.num_to_entry = {}
...
...
@@ -637,8 +635,6 @@ class Scope:
def generate_library_function_declarations(self, code):
# Generate extern decls for C library funcs used.
#if self.pow_function_used:
# code.putln("
%
s
double
pow
(
double
,
double
);
" % Naming.extern_c_macro)
pass
def defines_any(self, names):
...
...
tests/errors/e_modop.pyx
deleted
100644 → 0
View file @
b0a706e6
def
f
():
cdef
float
flt1
,
flt2
,
flt3
flt1
=
flt2
%
flt3
# error
_ERRORS
=
u"""
/Local/Projects/D/Pyrex/Source/Tests/Errors2/e_modop.pyx:3:13: Invalid operand types for '%' (float; float)
"""
tests/run/fmod.pyx
0 → 100644
View file @
28b719dd
__doc__
=
"""
>>> fmod(7, 1.25)
0.75
"""
def
fmod
(
double
a
,
double
b
):
return
a
%
b
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