summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/int_big_xor.py
diff options
context:
space:
mode:
authorDoug Currie <github.9.eeeeeee@spamgourmet.com>2016-01-30 22:35:58 -0500
committerDamien George <damien.p.george@gmail.com>2016-02-03 22:13:39 +0000
commit2e2e15cec2f85ece763f3f80152d759aecfad47c (patch)
treefc70fb1001ea72640bdb5f5b49c6951a65410817 /tests/basics/int_big_xor.py
parent5f3e005b6791634b104fa6385c8a9bf5ed1af164 (diff)
downloadmicropython-2e2e15cec2f85ece763f3f80152d759aecfad47c.tar.gz
micropython-2e2e15cec2f85ece763f3f80152d759aecfad47c.zip
py/mpz: Complete implementation of mpz_{and,or,xor} for negative args.
For these 3 bitwise operations there are now fast functions for positive-only arguments, and general functions for arbitrary sign arguments (the fast functions are the existing implementation). By default the fast functions are not used (to save space) and instead the general functions are used for all operations. Enable MICROPY_OPT_MPZ_BITWISE to use the fast functions for positive arguments.
Diffstat (limited to 'tests/basics/int_big_xor.py')
-rw-r--r--tests/basics/int_big_xor.py129
1 files changed, 129 insertions, 0 deletions
diff --git a/tests/basics/int_big_xor.py b/tests/basics/int_big_xor.py
index 1c6278b291..f14a763a4d 100644
--- a/tests/basics/int_big_xor.py
+++ b/tests/basics/int_big_xor.py
@@ -1,3 +1,6 @@
+
+# test + +
+
print(0 ^ (1 << 80))
print((1 << 80) ^ (1 << 80))
print((1 << 80) ^ 0)
@@ -7,3 +10,129 @@ print(a ^ (1 << 100))
print(a ^ (1 << 200))
print(a ^ a == 0)
print(bool(a ^ a))
+
+print( 97989513389222316022151446562729620153292831887555425160965597396
+ ^ 23716683549865351578586448630079789776107310103486834795830390982)
+
+print( 53817081128841898634258263553430908085326601592682411889506742059
+ ^ 37042558948907407488299113387826240429667200950043601129661240876)
+
+print( 26167512042587370698808974207700979337713004510730289760097826496
+ ^ 98456276326770292376138852628141531773120376436197321310863125849)
+
+print( 21085380307304977067262070503651827226504797285572981274069266136
+ ^ 15928222825828272388778130358888206480162413547887287646273147570)
+
+print( 40827393422334167255488276244226338235131323044408420081160772273
+ ^ 63815443187857978125545555033672525708399848575557475462799643340)
+
+print( 5181013159871685724135944379095645225188360725917119022722046448
+ ^ 59734090450462480092384049604830976376887859531148103803093112493)
+
+print( 283894311
+ ^ 86526825689187217371383854139783231460931720533100376593106943447)
+
+print( 40019818573920230246248826511203818792007462193311949166285967147
+ ^ 9487909752)
+
+# test - +
+
+print((-1 << 80) ^ (1 << 80))
+print((-1 << 80) ^ 0)
+
+print((-a) ^ (1 << 100))
+print((-a) ^ (1 << 200))
+print((-a) ^ a == 0)
+print(bool((-a) ^ a))
+
+print( -97989513389222316022151446562729620153292831887555425160965597396
+ ^ 23716683549865351578586448630079789776107310103486834795830390982)
+
+print( -53817081128841898634258263553430908085326601592682411889506742059
+ ^ 37042558948907407488299113387826240429667200950043601129661240876)
+
+print( -26167512042587370698808974207700979337713004510730289760097826496
+ ^ 98456276326770292376138852628141531773120376436197321310863125849)
+
+print( -21085380307304977067262070503651827226504797285572981274069266136
+ ^ 15928222825828272388778130358888206480162413547887287646273147570)
+
+print( -40827393422334167255488276244226338235131323044408420081160772273
+ ^ 63815443187857978125545555033672525708399848575557475462799643340)
+
+print( -5181013159871685724135944379095645225188360725917119022722046448
+ ^ 59734090450462480092384049604830976376887859531148103803093112493)
+
+print( -283894311
+ ^ 86526825689187217371383854139783231460931720533100376593106943447)
+
+print( -40019818573920230246248826511203818792007462193311949166285967147
+ ^ 9487909752)
+
+# test + -
+
+print(0 ^ (-1 << 80))
+print((1 << 80) ^ (-1 << 80))
+
+print(a ^ (-1 << 100))
+print(a ^ (-1 << 200))
+print(a ^ (-a) == 0)
+print(bool(a ^ (-a)))
+
+print( 97989513389222316022151446562729620153292831887555425160965597396
+ ^ -23716683549865351578586448630079789776107310103486834795830390982)
+
+print( 53817081128841898634258263553430908085326601592682411889506742059
+ ^ -37042558948907407488299113387826240429667200950043601129661240876)
+
+print( 26167512042587370698808974207700979337713004510730289760097826496
+ ^ -98456276326770292376138852628141531773120376436197321310863125849)
+
+print( 21085380307304977067262070503651827226504797285572981274069266136
+ ^ -15928222825828272388778130358888206480162413547887287646273147570)
+
+print( 40827393422334167255488276244226338235131323044408420081160772273
+ ^ -63815443187857978125545555033672525708399848575557475462799643340)
+
+print( 5181013159871685724135944379095645225188360725917119022722046448
+ ^ -59734090450462480092384049604830976376887859531148103803093112493)
+
+print( 283894311
+ ^ -86526825689187217371383854139783231460931720533100376593106943447)
+
+print( 40019818573920230246248826511203818792007462193311949166285967147
+ ^ -9487909752)
+
+# test - -
+
+print((-1 << 80) ^ (-1 << 80))
+
+print((-a) ^ (-1 << 100))
+print((-a) ^ (-1 << 200))
+print((-a) ^ (-a) == 0)
+print(bool((-a) ^ (-a)))
+
+print( -97989513389222316022151446562729620153292831887555425160965597396
+ ^ -23716683549865351578586448630079789776107310103486834795830390982)
+
+print( -53817081128841898634258263553430908085326601592682411889506742059
+ ^ -37042558948907407488299113387826240429667200950043601129661240876)
+
+print( -26167512042587370698808974207700979337713004510730289760097826496
+ ^ -98456276326770292376138852628141531773120376436197321310863125849)
+
+print( -21085380307304977067262070503651827226504797285572981274069266136
+ ^ -15928222825828272388778130358888206480162413547887287646273147570)
+
+print( -40827393422334167255488276244226338235131323044408420081160772273
+ ^ -63815443187857978125545555033672525708399848575557475462799643340)
+
+print( -5181013159871685724135944379095645225188360725917119022722046448
+ ^ -59734090450462480092384049604830976376887859531148103803093112493)
+
+print( -283894311
+ ^ -86526825689187217371383854139783231460931720533100376593106943447)
+
+print( -40019818573920230246248826511203818792007462193311949166285967147
+ ^ -9487909752)
+