本文介绍了签名零:这是一个错误吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我在Python 2.5上获得了以下行为(PowerPC上的OS X 10.4.8,如果它相关,则为。) (0.0,0.0) (-0.0,-0.0) 我希望在第一种情况下y为-0.0,在 秒内为0.0。如果以上被认为是一个错误,或者Python不是b $ b预计会尊重零的迹象?我正在工作的情况 涉及复杂的算术,其中分支削减,因此签署 零,很重要,如果上面的代码可能会很方便 依靠做正确的事。 Mark 解决方案 (0.0,0.0) (-0.0,-0.0) 我希望在第一种情况下y为-0.0,在 秒内为0.0。如果以上被认为是一个错误,或者Python不是b $ b预计会尊重零的迹象?我正在工作的情况 涉及复杂的算术,其中分支削减,因此签署 零,很重要,如果上面的代码可能会很方便 依靠做正确的事。 IIRC,float .__ repr__就像libc所做的一样。您是否在C程序中使用printf(%g,%g,0.0,-0.0)尝试了 ? 2007年3月11日星期日10:31,Mark Dickinson 写道: (0.0,0.0) (-0.0,-0.0) 我原本预计在第一个 情况下y为-0.0,在第二个情况下为0.0。如果上面的 被认为是一个错误,或者Python是不是预期 来纪念零的迹象?我正在处理一个涉及复杂算术的 情况,其中分支削减,因此签名零, 重要,它会如果上面的 代码可以依赖来做正确的 的事情就好用。 Mark 这可以用于某种原因 而不是x,y = -0.0,0.0 clumpy但结果是对的。 x = -0.0 y = 0.0 x,y (-0.0,0.0) jim-on-linux http:\\inqvista.com (0.0, 0.0) (0.0,0.0) 0.0 Terry Jan Reedy I get the following behaviour on Python 2.5 (OS X 10.4.8 on PowerPC,in case it''s relevant.)(0.0, 0.0)(-0.0, -0.0)I would have expected y to be -0.0 in the first case, and 0.0 in thesecond. Should the above be considered a bug, or is Python notexpected to honour signs of zeros? I''m working in a situationinvolving complex arithmetic where branch cuts, and hence signedzeros, are important, and it would be handy if the above code could berelied upon to do the right thing.Mark 解决方案(0.0, 0.0)(-0.0, -0.0)I would have expected y to be -0.0 in the first case, and 0.0 in thesecond. Should the above be considered a bug, or is Python notexpected to honour signs of zeros? I''m working in a situationinvolving complex arithmetic where branch cuts, and hence signedzeros, are important, and it would be handy if the above code could berelied upon to do the right thing.IIRC, float.__repr__ just does whatever libc does. Have you triedusing printf("%g, %g", 0.0, -0.0) in a C program?(0.0, 0.0)(-0.0, -0.0)I would have expected y to be -0.0 in the firstcase, and 0.0 in the second. Should the abovebe considered a bug, or is Python not expectedto honour signs of zeros? I''m working in asituation involving complex arithmetic wherebranch cuts, and hence signed zeros, areimportant, and it would be handy if the abovecode could be relied upon to do the rightthing.MarkThis works for some reasoninstead of x,y = -0.0, 0.0clumpy but the results are right.x = -0.0y= 0.0x,y(-0.0, 0.0)jim-on-linuxhttp:\\inqvista.com(0.0, 0.0)(0.0, 0.0)0.0Terry Jan Reedy 这篇关于签名零:这是一个错误吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-17 01:54
查看更多