-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_cpp.py
80 lines (63 loc) · 2.06 KB
/
test_cpp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/python3
import ctypes
from csbiginteger.BigInteger import BigInteger
# default is using 'csbiginteger_gmp.so'
# if using 'csbiginteger_mono.so' implementation (default), also requires 'csbiginteger_dotnet.dll' somewhere on path (get it inside package)
def main():
big = BigInteger()
print('length = ', len(big))
print('to_int = ', int(big))
print('to_str: ', str(big))
print('')
big1 = BigInteger(1)
print('length = ', len(big1))
print('to_int = ', int(big1))
print('to_str: ', str(big1))
print('')
bigM1 = BigInteger(-1)
print('length = ', len(bigM1))
print('to_int = ', int(bigM1))
print('to_str: ', str(bigM1))
print('')
big255 = BigInteger(255)
print('length = ', len(big255))
print('to_int = ', int(big255))
print('to_str: ', str(big255))
print('')
bigM10M = BigInteger(-1000000)
print('length = ', len(bigM10M))
print('to_int = ', int(bigM10M))
print('to_str: ', str(bigM10M))
print('')
big4293967296 = BigInteger(4293967296)
print('length = ', len(big4293967296))
print('to_int = SHOULD OVERFLOW')#, big4293967296.to_int())
print('to_str: ', str(big4293967296))
print('')
bigff = BigInteger(b'\xff')
print('length = ', len(bigff))
print('to_int = ', int(bigff))
print('to_str: ', str(bigff))
print('')
big100 = BigInteger('100') # base 10 implicit
print('length = ', len(big100))
print('to_int = ', int(big100))
print('to_str: ', str(big100))
print('')
big0001 = BigInteger('0x0001', 16) # big-endian input string
print('length = ', len(big0001))
print('to_int = ', int(big0001))
print('to_str: ', str(big0001))
print('')
big101 = big100 + big0001 # big100 + big0001
print('length = ', len(big101))
print('to_int = ', int(big101))
print('to_str: ', str(big101))
print('')
big99 = big100 - big0001 # big100 - big0001
print('length = ', len(big99))
print('to_int = ', int(big99))
print('to_str: ', str(big99))
return 0
if __name__ == '__main__':
main()