Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
a9dc9b8f
Commit
a9dc9b8f
authored
Jan 27, 2015
by
Damien George
Browse files
py: Fix comparison of minus-zero long int.
parent
e6a118ee
Changes
2
Hide whitespace changes
Inline
Side-by-side
py/mpz.c
View file @
a9dc9b8f
...
...
@@ -820,6 +820,10 @@ bool mpz_is_even(const mpz_t *z) {
}
int
mpz_cmp
(
const
mpz_t
*
z1
,
const
mpz_t
*
z2
)
{
// to catch comparison of -0 with +0
if
(
z1
->
len
==
0
&&
z2
->
len
==
0
)
{
return
0
;
}
int
cmp
=
(
int
)
z2
->
neg
-
(
int
)
z1
->
neg
;
if
(
cmp
!=
0
)
{
return
cmp
;
...
...
tests/basics/int_big_zeroone.py
View file @
a9dc9b8f
...
...
@@ -12,3 +12,17 @@ print([-c for c in cases])
print
([
~
c
for
c
in
cases
])
print
([
c
>>
1
for
c
in
cases
])
print
([
c
<<
1
for
c
in
cases
])
# comparison of 0/-0/+0
print
(
long_zero
==
0
)
print
(
long_neg_zero
==
0
)
print
(
long_one
-
1
==
0
)
print
(
long_neg_one
+
1
==
0
)
print
(
long_zero
<
1
)
print
(
long_zero
<
-
1
)
print
(
long_zero
>
1
)
print
(
long_zero
>
-
1
)
print
(
long_neg_zero
<
1
)
print
(
long_neg_zero
<
-
1
)
print
(
long_neg_zero
>
1
)
print
(
long_neg_zero
>
-
1
)
Write
Preview
Supports
Markdown
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