我知道 python 能够处理任意大整数,那么为什么在使用科学记数法时它不给我一个呢?为什么 1e23 与 10**23 有什么不同?
Python 2.7.3 (default, Aug 1 2012, 05:14:39)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> for x in range(30):
... x1 = eval('long(1e{})'.format(x))
... x2 = eval('long(1{})'.format('0' * x))
... print x1, 'OK' if x1 == x2 else 'YUCK!'
...
1 OK
10 OK
100 OK
1000 OK
10000 OK
100000 OK
1000000 OK
10000000 OK
100000000 OK
1000000000 OK
10000000000 OK
100000000000 OK
1000000000000 OK
10000000000000 OK
100000000000000 OK
1000000000000000 OK
10000000000000000 OK
100000000000000000 OK
1000000000000000000 OK
10000000000000000000 OK
100000000000000000000 OK
1000000000000000000000 OK
10000000000000000000000 OK
99999999999999991611392 YUCK!
999999999999999983222784 YUCK!
10000000000000000905969664 YUCK!
100000000000000004764729344 YUCK!
1000000000000000013287555072 YUCK!
9999999999999999583119736832 YUCK!
99999999999999991433150857216 YUCK!