Python integer ranges
来源:互联网 发布:机油加盟代理淘宝 编辑:程序博客网 时间:2024/06/07 11:28
43 down vote favorite
7
In Python, is there a way to get the largest integer one can use? Is there some pre-defined constant like INT_MAX?
pythoninteger
add a comment
1 Answer
activeoldestvotes
up vote86down vote accepted
Python has arbitrary precision integers so there is no true fixed maximum. You're only limited by available memory.
In Python 2, there are two types, int
and long
. int
s use a C type, while long
s are arbitrary precision. You can usesys.maxint
to find the maximumint
. But int
s are automatically promoted tolong
, so you usually don't need to worry about it:
sys.maxint + 1
works fine and returns a long
.
sys.maxint
does not even exist in Python 3, since int
andlong
were unified into a single arbitrary precisionint
type.
0 0
- Python integer ranges
- missing ranges of sorted integer array
- Ranges
- LeetCode OJ 系列之228 Summary Ranges --Python
- leetcode-Reverse Integer-python
- Reverse Integer leetcode python
- Reverse Integer (python)
- Roman to Integer(python)
- 7. Reverse Integer-python
- 【Leetcode】【python】Reverse Integer
- 【LeetCode with Python】 Reverse Integer
- redis python操作 string integer
- 【LeetCode】【Python题解】Reverse Integer
- leetcode Reverse Integer(python)
- 7. Reverse Integer Leetcode Python
- leetcode-07-reverse integer-python
- Reverse Integer Leetcode Python Java
- String to Integer (atoi)(python)
- linux的Socket编程解析
- Android性能优化典范(2)
- 把一个已有内容的.txt的文件清空
- CSS学习笔记 制作一个漂亮的表格
- JVM学习笔记(十一)---典型配置举例(二)
- Python integer ranges
- MMORPG游戏服务器技术选型参考
- 用ImageSwitcher实现图片动态切换
- JAVA NIO 基础(一)
- Golang初级系列教程-接口
- Visual Studio 2013快捷键
- 将多个对象读写到文件
- ViewPager使用中的一些小问题
- 深入理解java异常处理机制
sys.maxsize
can be used when you need an arbitrarily-large value. – mattdmJan 23 '12 at 19:07arbitrary
常用词汇- adj.任意的;专制的;武断的;霸道的
Adjective:based on or subject to individual discretion or preference or sometimes impulse or caprice;"an arbitrary decision""the arbitrary rule of a dictator"
"an arbitrary penalty"
"of arbitrary size and shape"
"an arbitrary choice"
"arbitrary division of the group into halves"
我的选择相当随意。
我不习惯你们那些随心所欲的标准。
这是个武断的决定。
precision
常用词汇- n.精确;精密度
- adj.精确的
Noun:the quality of being reproducible in amount or performance;"he handled it with the preciseness of an automaton""note the meticulous precision of his measurements"
- The teacher laid emphasis on the precision of the translation from the outset.
- Your report lacks precision.
- Every argument was stated with logical precision.
- These instruments are capable of very high precision.
- Different time have different concepts on precision or high precision mold.
查看更多老师从一开始就强调翻译准确性。
你的报告不够准确。
每一个论点都阐述得精确严密,符合逻辑。
这些仪器可以达到很高的精密度。
对于精密或超精密度模具,不同时期有不同的概念。
他用极为精确的话语发言。
精确的测量是生产互换零件和批量产品的关键。