sage: import scipy as sc sage: map(floor,sc.arange(0.0,1.2,0.1)) [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1]
On 1 Kwi, 21:17, ObsessiveMathsFreak <[email protected]> wrote: > Thanks for that, but I've run into another issue. I don't know whether > this is related to the sequence syntax or not > > sage: for n in [0.0,0.1,..,1.1]: > sage: print n, floor(n) > 0.000000000000000 0 > 0.100000000000000 0 > 0.200000000000000 0 > 0.300000000000000 0 > 0.400000000000000 0 > 0.500000000000000 0 > 0.600000000000000 0 > 0.700000000000000 0 > 0.800000000000000 0 > 0.900000000000000 0 > 1.00000000000000 0 <----- What's going on here? > 1.10000000000000 1 > > I realise that the numbers are floating point and so on, but something > appears to have gone awry here in a big way > > On Apr 1, 7:13 pm, Mike Hansen <[email protected]> wrote: > > > On Fri, Apr 1, 2011 at 8:08 PM, ObsessiveMathsFreak > > > <[email protected]> wrote: > > >> sage: [0,0.2,..,1] > > >> [0.000000000000000, 0.200000000000000, 0.400000000000000, > > >> 0.600000000000000, 0.800000000000000, 1.00000000000000] > > > > May sage installation appears to be having trouble with this syntax > > > > OK Here > > > sage: [0.0,0.2,..,0.9] > > > [0.000000000000000, 0.200000000000000, 0.400000000000000, > > > 0.600000000000000, 0.800000000000000] > > > > But what's going on here? > > > sage: [0.1,0.2,..,0.9] > > > [0.100000000000000, 0.200000000000000, 0.300000000000000, > > > 0.400000000000000, 0.500000000000000, 0.600000000000000, > > > 0.700000000000000, 0.800000000000000, 0.900000000000000] > > > The second number (0.2) is not the amount to be incremented each time, > > it's the next number in the sequence. Since, 0.2 differs from 0.1 by > > 0.1, each additional number in the sequence will be incremented by > > 0.1. > > > > Something's gone dreadfully wrong. > > > sage: [0.2,0.2,..,0.9] > > > OverflowError: cannot convert float infinity to integer > > > There's no difference between 0.2 and 0.2, so it will never make it to 0.9. > > > > Now I'm just confused. > > > sage: [0.2,0.1,..,0.9] > > > [] > > > Going down from 0.2 to 0.1 and so on, you'll never reach 0.9. > > > --Mike > > -- To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org
