为什么Python能够存储任意长度的长整数作为Java,C只能提供64位? 如果在Java中有这样的方法,请显示它。long-type in Python vs Java&C
0
A
回答
2
Java中有BigInteger类。
看到这个python帮助文件。
Plain integers (also just called integers) are implemented using long in C,
which gives them at least 32 bits of precision
(sys.maxint is always set to the maximum plain integer value for the current platform,
the minimum value is -sys.maxint - 1).
Long integers have unlimited precision.
基本上是一样的。在Java中,你可以使用。
- 字节 - 8位
- 短 - 16位
- INT - 32位
- 长 - 64位
- 的BigInteger
在蟒它自动改变由于其类型为弱分类,请参阅下面的python代码
>>> a = 1000
>>> type(a)
<type 'int'>
>>> a = 1000000000000000000000000000000000000000000000000000000000000000
>>> type(a)
<type 'long'>
在java中,你必须自己改变变量的类型。
0
Python存储无限制的长整数,只要有可用的地址空间,就可以存储大量数据。
至于Java中,使用的BigInteger类
相关问题
- 1. python in applescript:subprocess.call vs os.system in automator
- 2. inline asm in C++ in vs __asm
- 3. .isEqualTo vs .equals in java
- 4. map vs hash_map in C++
- 5. task.continuewith vs dataflow in c#
- 6. realloc vs malloc in C
- 7. Cassandra:使用LongType
- 8. astcanary vs python script in asterisk
- 9. Webscript vs java api in alfresco
- 10. self.propertyName vs _propertyName in objective-c
- 11. 从vs导入Python in Python 2.7
- 12. Boo vs C#vs Python?
- 13. ECB vs global vs cscope .. in emacs
- 14. C#List implementation ... in Java
- 15. locale in C++ n java
- 16. 内存:Java vs C++ vs JS
- 17. Math.pi vs double and rounding via printf in java
- 18. instance_eval vs class_eval in module
- 19. C++ Exprtk vs Python eval()
- 20. concat in FSharp.Core.String vs Concat in System.String
- 21. AS3 - for(... in ...)vs for each(... in ...)
- 22. Datagrid in vs 2010
- 23. datetime in C#vs,SQL和GETDATE()from SQL Server
- 24. string&vs. wstring&in runtime_error
- 25. $ injector.instantiate VS $ injector.get VS $ injector.invoke in angularjs
- 26. C main vs Java main
- 27. Java EE + JKS vs C#
- 28. ASPX/c#vs Java EE
- 29. C#vs Java泛型
- 30. Moshi vs Gson in android
['BigInteger'](https://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html)具有任意精度。 – August 2014-11-14 21:51:12
你可能想读这个 - http://programmers.stackexchange.com/questions/128589/how-to-handle-large-numbers – ha9u63ar 2014-11-14 21:52:31