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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
7b3554bd
Commit
7b3554bd
authored
Sep 13, 2008
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unsigned arithmatic, ticket #54
parent
c0e500d4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
4 deletions
+28
-4
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+9
-4
tests/run/unsigned.pyx
tests/run/unsigned.pyx
+19
-0
No files found.
Cython/Compiler/PyrexTypes.py
View file @
7b3554bd
...
...
@@ -1181,11 +1181,16 @@ def widest_numeric_type(type1, type2):
# Given two numeric types, return the narrowest type
# encompassing both of them.
if
type1
.
is_enum
and
type2
.
is_enum
:
widest_type
=
c_int_type
elif
type2
.
rank
>
type1
.
rank
:
widest_type
=
type2
return
c_int_type
elif
type1
is
type2
:
return
type1
elif
(
type1
.
signed
and
type2
.
signed
)
or
(
not
type1
.
signed
and
not
type2
.
signed
):
if
type2
.
rank
>
type1
.
rank
:
return
type2
else
:
return
type1
else
:
widest_type
=
type1
return
sign_and_rank_to_type
[
min
(
type1
.
signed
,
type2
.
signed
),
max
(
type1
.
rank
,
type2
.
rank
)]
return
widest_type
def
simple_c_type
(
signed
,
longness
,
name
):
...
...
tests/run/unsigned.pyx
0 → 100644
View file @
7b3554bd
__doc__
=
"""
>>> test_signed()
3 <type 'int'>
9 <type 'long'>
6 <type 'long'>
12 <type 'long'>
"""
cdef
int
i
=
1
cdef
long
l
=
2
cdef
unsigned
int
ui
=
4
cdef
unsigned
long
ul
=
8
def
test_signed
():
print
i
+
l
,
type
(
i
+
l
)
print
i
+
ul
,
type
(
i
+
ul
)
print
ui
+
l
,
type
(
ui
+
l
)
print
ui
+
ul
,
type
(
ui
+
ul
)
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