[BUG][3.2][Linux] Float arithmetic: Squeak<->C Float conversion problem?

Richard A. O'Keefe squeak-dev at lists.squeakfoundation.org
Fri Oct 25 00:14:06 UTC 2002


Stephan Rudlof <sr at evolgo.de> wrote:
	"Bug"
	"Wrong:"
	| onePlusEpsilon epsilon |
	onePlusEpsilon _ 1.0 basicAt: 2 put: 1; yourself.
	epsilon _ onePlusEpsilon - 1.0.
	epsilon = 0.0 -> true
	[snip]
	Very weired...
	Squeak<->C Float conversion problem?

As I have explained to him privately, this is just the long-standing
and well known "literals in a method are shared and if you smash one
you will get what you deserve" problem.  Change either of the
1.0 literals to (0.5+0.5) and there is no longer any changed shared
literal.  Alternatively, change the first statement to
	onePlusEpsilon := (1.0 shallowCopy) basicAt: 2 put: 1; yourself.
and again the problem goes away.
	
Apparently his question about Float>>epsilon went to the mailing list;
the conclusion is that Float>>epsilon is 100% correct as I wrote it,
even if it does have one more digit than Squeak happens to need.




More information about the Squeak-dev mailing list