Re: Python syntax in Lisp and Scheme

From: Andrew Dalke (adalke_at_mindspring.com)
Date: 10/07/03


Date: Tue, 07 Oct 2003 05:41:52 GMT

Gerrit Holl:
> a = 2
> a = 1 + 1
> a = math.sqrt(4)
> a = int((sys.maxint+1) ** (1/31))
>
> ...all mean the same thing.

Be careful with that. The first two return the integer 4, the third returns
the floating point number 4.0 and the last returns 1 because 1/31 is
0 (unless you are using true division). Even if you use 1/31. you'll
get a different value on a 32 bit machine vs. a 64 bit machine.

pedantically yours,

                    Andrew
                    dalke@dalkescientific.com



Relevant Pages

  • Re: Double comparison problem
    ... Dietmar Kuehl wrote: ... > chris wrote: ... After all, comparing floating ... as long as are careful:) But like you say you ...
    (comp.lang.cpp)
  • Re: terrible bug in Mathematica (//N), but why????
    ... the first expression and look at the numbers you get. ... A careful ... study of the results of floating point arithmetic may reveal why ... ask why does Mathematica not make this mistake for 44 or 42 but for 43? ...
    (sci.math.symbolic)
  • Re: Problem in Float Arithmetic
    ... problem and adding integers cast to double precision isn't. ... I'll be careful where I jump into a topic in future. ... But the topic was floating point subtraction errors, and illustrated the problems you run into if you consider floating point numbers to be in any sense "exact". ...
    (microsoft.public.vc.mfc)
  • Re: Jingle Bells subliminal message in reverse
    ... LOL. ... Hahaha:) Be careful there's a lot of those types of things ... floating around on the internet. ...
    (alt.support.stop-smoking)