Re: Inconsistent results from int(floatNumber)

2010-10-26 Thread gershar
On Oct 25, 5:44 pm, gershar wrote: > I had some problems with some Python projects that gave variable > results that I could not track down. Eventually and reluctantly I > converted them to Java. Later, when I had more time I tried to analyze > what the Python code was doing and found something st

Re: Inconsistent results from int(floatNumber)

2010-10-25 Thread Ian
On Oct 25, 4:25 pm, Terry Reedy wrote: > The binary float resulting from the conversion of .1 is slightly greater > than .1, so this increases i by slightly more than .1 > > >    z = i * 10.0 > > so z is increased be lightly more that 1 It should also be pointed out that Java in fact does the sam

Re: Inconsistent results from int(floatNumber)

2010-10-25 Thread Terry Reedy
On 10/25/2010 5:44 PM, gershar wrote: I had some problems with some Python projects that gave variable results that I could not track down. Eventually and reluctantly I converted them to Java. Later, when I had more time I tried to analyze what the Python code was doing and found something strang

Re: Inconsistent results from int(floatNumber)

2010-10-25 Thread Dave Angel
On 2:59 PM, gershar wrote: I had some problems with some Python projects that gave variable results that I could not track down. Eventually and reluctantly I converted them to Java. Later, when I had more time I tried to analyze what the Python code was doing and found something strange. The foll

Re: Inconsistent results from int(floatNumber)

2010-10-25 Thread Ian
On Oct 25, 3:44 pm, gershar wrote: > It looks like a rounding problem but on the surface there is nothing > to round. I am aware that there are rounding limitations with floating > point arithmetic but the value passed to int() is always correct. No, it isn't: >>> for x in xrange(5): ... i +=

Inconsistent results from int(floatNumber)

2010-10-25 Thread gershar
I had some problems with some Python projects that gave variable results that I could not track down. Eventually and reluctantly I converted them to Java. Later, when I had more time I tried to analyze what the Python code was doing and found something strange. The following snippet illustrates the