mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
...
This commit is contained in:
parent
ffbb9af45e
commit
2c68dd63a5
@ -8,6 +8,11 @@ Unlike cpython, pkpy's `int` is of limited precision (64-bit).
|
|||||||
For arbitrary sized integers, we provide a builtin `long` type, just like python2's `long`.
|
For arbitrary sized integers, we provide a builtin `long` type, just like python2's `long`.
|
||||||
`long` is implemented via pure python in [_long.py](https://github.com/blueloveTH/pocketpy/blob/main/python/_long.py).
|
`long` is implemented via pure python in [_long.py](https://github.com/blueloveTH/pocketpy/blob/main/python/_long.py).
|
||||||
|
|
||||||
|
!!!
|
||||||
|
This feature is still under development.
|
||||||
|
Some operations are missing, and some operations are not optimized.
|
||||||
|
!!!
|
||||||
|
|
||||||
### Create a long object
|
### Create a long object
|
||||||
|
|
||||||
You can use `L` suffix to create a `long` literal from a decimal literal.
|
You can use `L` suffix to create a `long` literal from a decimal literal.
|
||||||
@ -25,8 +30,3 @@ a = 2L # use `L` suffix to create a `long` object
|
|||||||
print(a ** 1000)
|
print(a ** 1000)
|
||||||
# 10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376L
|
# 10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376L
|
||||||
```
|
```
|
||||||
|
|
||||||
!!!
|
|
||||||
This feature is still under development.
|
|
||||||
Some operations are missing, and some operations are not optimized.
|
|
||||||
!!!
|
|
@ -1,12 +1,5 @@
|
|||||||
from c import sizeof
|
# after v1.2.2, int is always 64-bit
|
||||||
|
PyLong_SHIFT = 60//2 - 1
|
||||||
# https://www.cnblogs.com/liuchanglc/p/14203783.html
|
|
||||||
if sizeof('void_p') == 4:
|
|
||||||
PyLong_SHIFT = 28//2 - 1
|
|
||||||
elif sizeof('void_p') == 8:
|
|
||||||
PyLong_SHIFT = 60//2 - 1
|
|
||||||
else:
|
|
||||||
raise NotImplementedError
|
|
||||||
|
|
||||||
PyLong_BASE = 2 ** PyLong_SHIFT
|
PyLong_BASE = 2 ** PyLong_SHIFT
|
||||||
PyLong_MASK = PyLong_BASE - 1
|
PyLong_MASK = PyLong_BASE - 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user