博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Python integer ranges
阅读量:4029 次
发布时间:2019-05-24

本文共 2301 字,大约阅读时间需要 7 分钟。

43
7

In Python, is there a way to get the largest integer one can use? Is there some pre-defined constant like INT_MAX?

 

1 Answer

86
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. ints use a C type, while longs are arbitrary precision. You can usesys.maxint to find the maximum int. But ints 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 precision int type.

 
19  
Note that in Python 3 (and Python 2.6 and up)sys.maxsize can be used when you need an arbitrarily-large value. – 
Jan 23 '12 at 19:07

arbitrary

常用词汇
['ɑːbɪtrəri]
   
['ɑːrbətreri]
   
  • 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"
用作形容词 (adj.)
  1. My choice was quite arbitrary.
    我的选择相当随意。
  2. I'm not used to your arbitrary standards.
    我不习惯你们那些随心所欲的标准。
  3. This is an arbitrary decision.
    这是个武断的决定。
adj.
(形容词)
  1. arbitrary作“任意的,主观的”解时,主要指不按照客观实际办事; 作“专横的,无理的,独断专行的”解时,主要指无视宪法与法律或别人的利益而是按照自己的意愿任意行使或滥用权力。

precision

常用词汇
[prɪ'sɪʒn]
   
[prɪ'sɪʒn]
   
  • 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"
用作名词 (n.)
  1. The teacher laid emphasis on the precision of the translation from the outset.
    老师从一开始就强调翻译准确性。
  2. Your report lacks precision.
    你的报告不够准确。
  3. Every argument was stated with logical precision.
    每一个论点都阐述得精确严密,符合逻辑。
  4. These instruments are capable of very high precision.
    这些仪器可以达到很高的精密度。
  5. Different time have different concepts on precision or high precision mold.
    对于精密或超精密度模具,不同时期有不同的概念。
用作形容词 (adj.)
  1. He spoke with pluperfect precision.
    他用极为精确的话语发言。
  2. Precision measurement is the key to producing interchangeable parts and mass producing goods.
    精确的测量是生产互换零件和批量产品的关键。

转载地址:http://aihbi.baihongyu.com/

你可能感兴趣的文章
苹果Swift编程语言入门教程【中文版】
查看>>
捕鱼忍者(ninja fishing)之游戏指南+游戏攻略+游戏体验
查看>>
iphone开发基础之objective-c学习
查看>>
iphone开发之SDK研究(待续)
查看>>
计算机网络复习要点
查看>>
Variable property attributes or Modifiers in iOS
查看>>
NSNotificationCenter 用法总结
查看>>
C primer plus 基础总结(一)
查看>>
剑指offer算法题分析与整理(一)
查看>>
剑指offer算法题分析与整理(三)
查看>>
部分笔试算法题整理
查看>>
Ubuntu 13.10使用fcitx输入法
查看>>
pidgin-lwqq 安装
查看>>
mint/ubuntu安装搜狗输入法
查看>>
C++动态申请数组和参数传递问题
查看>>
opencv学习——在MFC中读取和显示图像
查看>>
retext出现Could not parse file contents, check if you have the necessary module installed解决方案
查看>>
pyQt不同窗体间的值传递(一)——对话框关闭时返回值给主窗口
查看>>
linux mint下使用外部SMTP(如网易yeah.net)发邮件
查看>>
北京联通华为光猫HG8346R破解改桥接
查看>>