[SciPy-user] strange addition behavior

John Hassler hasslerjc at comcast.net
Thu Feb 14 08:18:21 EST 2008


It works correctly for me.  Does this snippit (by itself) give the 
incorrect answer, or does it have to be inside of a larger program?
john

Chris Lee wrote:
> Hi All,
>
> I have encountered some very strange addition behavior. A quick web 
> search didn't reveal anything obvious, so I expect that I am 
> misunderstanding some aspect of python here.
>
> Code snip:
>
> print 'dividing up the X axis'
> print 'current range is ', xCMin, xCMax
> xSpace = 0.5*(xCMax - xCMin)
> print 'the new span is ', xSpace
> xNew = xSpace + xCMin
> print 'the boundary value is ', xNew
>
> xCMin = -0.03
> xCMax = 0.05
> xSpace = 0.04
> xNew = 0.07
>
> I expect that xNew = 0.01
>
> The obvious answer is the addition is using the absolute value of both 
> parties.... but if this is so, then that is very scary
>
> Running on Intel Core 2 Duo, Ubuntu linux, python 2.5.1, numpy 1.0.3
>
> Cheers
> Chris
>
>   



More information about the SciPy-User mailing list