"Alan Gauld" wrote in message
news:ht6v97$63...@dough.gmane.org...
"Neven Gorsic" wrote
I run into Python error in rounding and not know how to predict when it
will
occur in order to prevent wrong result.
It depends how you define wrong. When I was at scvhool the rules f
or rounding dec
"Neven Goršić" wrote
It's pity that Python has such unreliable functions so
you never know in advanced when you will hit new one ...
The functions are not unreliable. That would imply they
give out unpredictable answers. In fact the answers are
completely predictable and consistent and correc
"Neven Gorsic" wrote
I run into Python error in rounding and not know how to predict when
it will
occur in order to prevent wrong result.
It depends how you define wrong. When I was at scvhool the rules f
or rounding decimals said that if it ended in 5 you rounded to the
nearest even digit.
correct, it is a floating point issue regardless of language.. it's
not just Python. you cannot accurately represent repeating fractions
with binary digits (bits). more info specific to Python here:
http://docs.python.org/tutorial/floatingpoint.html
also, keep in mind that '%f' is not a rounding o
hi,
thanks for the feedback, it is much appreciated.
On Fri, May 21, 2010 at 7:54 PM, bob gailer wrote:
> Also note that the database function creates a local variable "database" but
> does nothing with it.
> When the function terminates that variable is lost.
> Did you intend to return it?
yes,
On 5/21/2010 8:30 AM Neven Goršić said...
Thanks!
It's pity that Python has such unreliable functions so you never know in
advanced when you will hit new one ...
The problem is with floats, and all languages suffer similarly. Most of
us develop various techniques for avoiding these types of i
Also note that the database function creates a local variable "database"
but does nothing with it.
When the function terminates that variable is lost.
Did you intend to return it?
Also it is not good practice to use the same name for a function and a
variable.
--
Bob Gailer
919-636-4239
Chapel
On 5/21/2010 5:35 AM, Norman Khine wrote:
hello,
i have this script, but i am stuck at the loop, if the user types an
incorrect database id:
http://paste.lisp.org/+25D3
how would i write the exception correctly?
Which line of code could raise the ValueError exception?
That line should be
Thanks for the assistance and the article.
Neven
--
On Fri, May 21, 2010 at 5:35 PM, Lie Ryan wrote:
> On 05/22/10 01:30, Neven Goršić wrote:
> > Thanks!
> > It's pity that Python has such unreliable functions so you never know in
> > advanced when you will hit new one ...
On 05/22/10 01:30, Neven Goršić wrote:
> Thanks!
> It's pity that Python has such unreliable functions so you never know in
> advanced when you will hit new one ...
Well, it's not Python but the machine. Floating point number is not Real
numbers; there are certain limitations imposed by physical l
Thanks!
It's pity that Python has such unreliable functions so you never know in
advanced when you will hit new one ...
---
On Fri, May 21, 2010 at 2:14 PM, Lie Ryan wrote:
> On 05/21/10 20:17, Neven Goršić wrote:
> > Hi!
> >
> > I run into Python error in rounding and n
On 05/21/10 20:17, Neven Goršić wrote:
> Hi!
>
> I run into Python error in rounding and not know how to predict when it will
> occur in order to prevent wrong result.
That's because it's floating point number.
> What can I do to assure accurate result?
Use decimal module to do precise control
Hi!
I run into Python error in rounding and not know how to predict when it will
occur in order to prevent wrong result.
What can I do to assure accurate result?
>>> "%.2f" % 0.445
'0.45' correct
>>> "%.2f" % 0.455
'0.46' correct
hello,
i have this script, but i am stuck at the loop, if the user types an
incorrect database id:
http://paste.lisp.org/+25D3
how would i write the exception correctly?
norman
--
%>>> "".join( [ {'*':'@','^':'.'}.get(c,None) or
chr(97+(ord(c)-83)%26) for c in ",adym,*)&uzq^zqf" ] )
__
14 matches
Mail list logo