[racket-dev] .1 evaluates to 0.0 [was Re: plot doesn't plot (inexact->exact: no exact representation for +nan.0)]

From: Marijn (hkBst at gentoo.org)
Date: Tue Dec 27 08:26:42 EST 2011

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 24-12-11 16:23, Matthew Flatt wrote:
> At Wed, 14 Dec 2011 16:49:23 +0100, Marijn wrote:
>> #lang racket (* .1 pi)
>> 
>> produces 0.0 reliably in a freshly started drracket even when 
>> rerunning it, but:
>> 
>> $ racket -e '(* .1 pi)' 0.3141592653589793
>> 
>> and the program:
>> 
>> #lang racket pi (* .1 pi)
>> 
>> on the first run (drracket again) produces:
>> 
>> 3.141592653589793 0.0
>> 
>> while on subsequent runs it produces:
>> 
>> 3.141592653589793 0.3141592653589793
> 
> Thanks --- this is very helpful!
> 
> I'm still stumped, unfortunately. It looks the same as PR 12070,
> which we never figured out:
> 
> http://bugs.racket-lang.org/query/?debug=&database=default&cmd=view+audit-trail&cmd=view&pr=12070

Interesting!,
> 
though it is a bit hard to read the Audit Trail because
everything is jumbled together.

I reproduce that bug and step 7) and 8) can be replaced with a single
re-evaluate for me.

It seems to indicate very clearly that the problem is in the floating
point start-up somehow and has nothing to do with `pi' or variable
references.

Another possibility would be that multiplication (*) was at fault, but
my new smallest test-case rules that out:

#lang racket
.1

=> 0.0

And actually it works also directly in the REPL without running any
program:

Welcome to DrRacket, version 5.2.0.7--2011-12-15(-/f) [3m].
Language: racket; memory limit: 128 MB.
> .1
0.0
> 1
1
> .1
0.0
> .2
0.0
> .3
0.0
> .4
0.0
> .5
0.0
> .6
0.0
> .7
0.0
> .8
0.0
> .9
0.0
> 1.0
1.0
> .1
0.1

So should we look at the byte-code produced for this (how does one do
that and what is the expected code)?
Is there some way to invoke racket from the command line in such a way
that it behaves like the drracket initial repl?
How does one run the byte-code?

What external suspects are there? I suppose gcc, but are there any
other? My CFLAGS are set to a very conservative AFAIK
CFLAGS="-march=native -ggdb -O2 -pipe", currently on version 4.5.3.

Marijn


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk75x5IACgkQp/VmCx0OL2xZRACcC8dubYCSNXScyOG8wdJQxxN1
xAgAnRVKv8YpTWODEKn2qEMMhcXHZLSk
=n+xT
-----END PGP SIGNATURE-----


Posted on the dev mailing list.