爲什麼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