Re: floating point rounding

2007-03-10 Thread greg
John Henry wrote: > Or more precisely: > > round(0.014999,2) No, that *won't* solve the problem. Using a slightly different example, >>> x = 1.5 * 0.1 >>> x 0.15002 >>> round(x, 2) 0.14999 The problem is that floats are stored internally in binary, not de

Re: floating point rounding

2007-03-09 Thread hg
John Henry wrote: > On Mar 9, 5:45 am, hg <[EMAIL PROTECTED]> wrote: >> hg wrote: >> > Hi, >> >> > Here is my issue: >> >> > f = 1.5 * 0.01 >> > f >> >>> 0.014999 >> > '%f' % f >> >>>'0.015000' >> >> > But I really want to get 0.02 as a result ... is there a way out ? >> >> > Thanks, >

Re: floating point rounding

2007-03-09 Thread John Henry
On Mar 9, 5:45 am, hg <[EMAIL PROTECTED]> wrote: > hg wrote: > > Hi, > > > Here is my issue: > > > f = 1.5 * 0.01 > > f > >>> 0.014999 > > '%f' % f > >>>'0.015000' > > > But I really want to get 0.02 as a result ... is there a way out ? > > > Thanks, > > > hg > > round Or more precise

Re: floating point rounding

2007-03-09 Thread hg
hg wrote: > Hi, > > Here is my issue: > > f = 1.5 * 0.01 > f >>> 0.014999 > '%f' % f >>>'0.015000' > > > But I really want to get 0.02 as a result ... is there a way out ? > > Thanks, > > hg round -- http://mail.python.org/mailman/listinfo/python-list

floating point rounding

2007-03-09 Thread hg
Hi, Here is my issue: f = 1.5 * 0.01 f >> 0.014999 '%f' % f >>'0.015000' But I really want to get 0.02 as a result ... is there a way out ? Thanks, hg -- http://mail.python.org/mailman/listinfo/python-list