草庐IT

integer-overflow

全部标签

java - 溢出如何在java中工作?

我读过有关溢出的内容,我知道“溢出是指数字太大以至于不再适合数据类型,因此系统“环绕”到下一个最低值并从那里开始计数".例如:shorts=(short)1921222;//Storedas20678在那个例子中,我们从-32768(Short.MIN_VALUE)开始计数,但是当我尝试用另一种整数数据类型证明时,它似乎不起作用同样的方法...byteb=(byte)400;//Storedas-112上面的例子从0开始计数,这是我发现得到-112的唯一方法我不知道我做错了什么。 最佳答案 JavaLanguageSpecifica

python - Kaggle 类型错误 : slice indices must be integers or None or have an __index__ method

我正在尝试在Kaggle上绘制seaborn直方图笔记本这样:sns.distplot(myseries,bins=50,kde=True)但是我得到这个错误:TypeError:sliceindicesmustbeintegersorNoneorhavean__index__method这是Kaggle笔记本:https://www.kaggle.com/asindico/slice-indices-must-be-integers-or-none/这是系列头:058500001600000025700000313100000416331452Name:price_doc,dtype

python - 洪水填充期间的致命 Python 错误 : Cannot recover from stack overflow.

我已经走到了死胡同,在过度(和不成功)谷歌搜索之后,我需要帮助。我正在构建一个简单的PyQt4小部件,它位于一个60x80正方形的网格中,每个正方形都初始化为None。如果用户单击该框,它会根据左键单击的次数更改颜色,由以下列表定义:self.COLORS=[(0,0,255),#WATER(255,210,128),#SAND(0,128,0),#GREEN(255,255,0),#YELLOW(255,165,0),#ORANGE(255,0,0)#RED]如果用户单击鼠标右键,它会使用常见的递归洪水填充算法对一个区域进行洪水填充。这非常适用于小空间,但是如果空间足够大,程序将失败

python - "TypeError: string indices must be integers"尝试在 python 中制作二维数组时

我对Python(和编码)还是个新手,我只想根据玩家的需求创建一个棋盘(用于主机游戏)。基本上就是这样......importarrayprint("Whatsizedoyouwanttheboard?")Boardsize=input()Tablero=array('b'[Boardsize,Boardsize])forwinBoardsize:forhinBoardsize:Boardsize(w)(h).append('.')print(Tablero)至少那是我的想法,但编译器说:Tablero=array('b'[Boardsize,Boardsize])TypeError:

python - 如何修复此 python 错误?溢出错误 : cannot convert float infinity to integer

它给我这个错误:Traceback(mostrecentcalllast):File"C:\Users\Public\SoundLog\Code\CódigoPython\SoundLog\Plugins\NoisePlugin.py",line113,inonPaintdc.DrawLine(valueWI,valueHI,valueWF,valueHF)File"C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\_gdi.py",line3177,inDrawLinereturn_gdi_.DC_DrawLine(*args,*

python - 获取 IOError : [Errno Input overflowed] -9981 when setting PyAudio Stream input and output to True

我正在尝试在我的Mac(OS10.7.2)上运行以下代码(来自PyAudio文档的示例):importpyaudioimportsyschunk=1024FORMAT=pyaudio.paInt16CHANNELS=1RATE=44100RECORD_SECONDS=5p=pyaudio.PyAudio()stream=p.open(format=FORMAT,channels=CHANNELS,rate=RATE,input=True,output=True,frames_per_buffer=chunk)print"*recording"foriinrange(0,44100/ch

python - 获取 numpy 以警告整数溢出

我主要使用python,因为不必担心整数溢出而被宠坏了。现在用的是numpy,又得操心了。我希望numpy在溢出的情况下出错,但它似乎不适用于int64。importnumpynumpy.seterr(all='raise')print("{:,}".format(numpy.prod([10]*50)))#-5,376,172,055,173,529,600print("{:,}".format(numpy.int64(3200000000)*numpy.int64(3200000000)))#-8,206,744,073,709,551,616print("{:,}".format

python - 运行时警告 : overflow encountered in ubyte_scalars

我是Python的新手,这是我编写脚本的第一件事,我只是想知道我能做些什么来删除这个警告:Warning(fromwarningsmodule):File"C:\Users\Luri\Desktop\BotStuff\ImageSaver.py",line76currentdiff=abs(anread[w,h])-abs(bnread[w,h])RuntimeWarning:overflowencounteredinubyte_scalars我已经尝试用谷歌搜索答案,但就解决这个问题而言,我并没有明确的答案。我正在尝试编写一个程序,该程序将从光标周围的矩形中获取的不断更新的图像与我正

python - TypeError : list indices must be integers, 不是字典

我的json文件看起来像这样,我试图在for循环中访问元素syslog。{"cleanup":{"folderpath":"/home/FBML7HR/logs","logfilename":""},"preparation":{"configuration":{"src_configfile":"src.cfg","dest_configfile":"/var/home/FBML7HR/etc/vxn.cfg"},"executable_info1":[{"login_info":{"hostname":"10.4.0.xxx","username":"***","password"

python - 一维 numpy 连接 : TypeError: only integer scalar arrays can be converted to a scalar index

这个问题在这里已经有了答案:Concatenatingtwoone-dimensionalNumPyarrays(6个答案)关闭5年前。我想将numpy数组存储到另一个numpy数组中我正在使用np.concatenate这是我的代码x=np.concatenate(x,s_x)这些是x和s_x的类型和形状Typeofs_x:,Shapeofs_x:(173,)Typeofx:(0,),Shapeofx:(0,)这是显示的错误TypeError:onlyintegerscalararrayscanbeconvertedtoascalarindex