# Zero division error!

Aruna arunaaruna at hotmail.com
Fri Aug 3 21:07:57 CEST 2001

```Hi,
I guess,yo were missing the 'Float' while declaring the 'zeros'. Check out.

Aruna Kinjarapu.
625 Brister, #2,
Memphis, Tennessee.

prem at engr.uky.edu (Prem Rachakonda) wrote in message news:<e56d8da7.0108021621.67556a14 at posting.google.com>...
> Hi,
>    That was a perfect guess. I intialized d with zeros(). Initially I
> didn't use 'Float'. But now even when I use Float it doesn't work. I
> think, I have a bug in my code..and my not be in Python...Let me
> check..
>
> Thanks,
> Prem.
> "Tim Hochberg" <tim.hochberg at ieee.org> wrote in message news:<oCga7.75798\$Cy.10897029 at news1.rdc1.az.home.com>...
> > "Prem Rachakonda" <prem at engr.uky.edu> wrote in message
> > news:Pine.LNX.4.21.0108021330570.19621-100000 at seahawk.ecc.engr.uky.edu...
> > > Hi,
> > >   I am writing a script for 'cubic spline interpolation' and when there is
> > > a float value = 0.004, it is rounded off to zero and I am getting a Zero
> > > Division error. Is it a python bug?
> > >
> > > Prem.
> > >
> > > x=array([2.056, 2.06, 2.064, 2.068, 2.072, 2.076, 2.08, 2.084, 2.088,
> > > 2.092, 2.096, 2.1, 2.104])
> > > ..
> > > ..
> > > ..
> > > d[0]=x[1]-x[0]
> > > c[1]=(y[1]-y[0])/d[0]
> > >
> > > Here d[0] is 0.004(equally spaced points) and is being considered as 0 and
> > > I am getting this error.
> >
> >
> > You haven't posted enough code to be sure, but I'm going to make some
> > guesses.
> >
> > (1) array is Numeric.array
> > (2) d is created in a way similar to zeros([N])
> >
> > If that's the case, what happening is that d is an array of ints, not floats
> > (int is the default). That means that when attributes are set using floats,
> > they are silently truncated to ints in the array. This is somewhat of a
> > misfeature of Numeric in my opinion, but I don't think it's actually a bug.
> > Assuming that your are actually using zeros to create d, you could use