2e2e15cec2
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.
145 lines
5.0 KiB
Python
145 lines
5.0 KiB
Python
print(0 | (1 << 80))
|
|
|
|
a = 0xfffffffffffffffffffffffffffff
|
|
print(a | (1 << 200))
|
|
|
|
|
|
# test + +
|
|
|
|
print(0 | (1 << 80))
|
|
print((1 << 80) | (1 << 80))
|
|
print((1 << 80) | 0)
|
|
|
|
a = 0xfffffffffffffffffffffffffffff
|
|
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)
|
|
|
|
|