Hi,
The following code
((-10 to: 10) collect: [ :each | each * Float pi ]) = ((((-10 to: 10) collect: [ :each | each * Float pi ]) collect: [ :each | each asString]) collect: [ :each | Float readFrom: each ])
returns true on Pharo 1.4 and false on Squeak 4.3 Some of the Floats in the array compare equal, some not.
Similary, (10 raisedTo: -100) asFloat
prints as '1.0e-100' in Pharo and as ' 9.99999999999999e-101' in Squeak.
I know that comparing Floats on equality is often dangerous and that #closeTo: is better. But I would like to understand how there could be such a difference between the two.
Nicolas ?
Thx,
Sven
On 25.04.2012, at 13:20, Sven Van Caekenberghe wrote:
Hi,
The following code
((-10 to: 10) collect: [ :each | each * Float pi ]) = ((((-10 to: 10) collect: [ :each | each * Float pi ]) collect: [ :each | each asString]) collect: [ :each | Float readFrom: each ])
returns true on Pharo 1.4 and false on Squeak 4.3 Some of the Floats in the array compare equal, some not.
Similary, (10 raisedTo: -100) asFloat
prints as '1.0e-100' in Pharo and as ' 9.99999999999999e-101' in Squeak.
I know that comparing Floats on equality is often dangerous and that #closeTo: is better. But I would like to understand how there could be such a difference between the two.
If you use storeString instead of asString it will be the same. E.g.
(10 raisedTo: -100) asFloat storeString ==> '1.0e-100'
- Bert -
Yes, Pharo is a bit ahead, I have a change in Squeak/inbox to align Squeak printing...
Nicolas
Le 25 avril 2012 22:28, Bert Freudenberg bert@freudenbergs.de a écrit :
On 25.04.2012, at 13:20, Sven Van Caekenberghe wrote:
Hi,
The following code
((-10 to: 10) collect: [ :each | each * Float pi ]) = ((((-10 to: 10) collect: [ :each | each * Float pi ]) collect: [ :each | each asString]) collect: [ :each | Float readFrom: each ])
returns true on Pharo 1.4 and false on Squeak 4.3 Some of the Floats in the array compare equal, some not.
Similary, (10 raisedTo: -100) asFloat
prints as '1.0e-100' in Pharo and as ' 9.99999999999999e-101' in Squeak.
I know that comparing Floats on equality is often dangerous and that #closeTo: is better. But I would like to understand how there could be such a difference between the two.
If you use storeString instead of asString it will be the same. E.g.
(10 raisedTo: -100) asFloat storeString ==> '1.0e-100'
- Bert -
http://lists.squeakfoundation.org/pipermail/squeak-dev/2011-November/161915.... http://lists.squeakfoundation.org/pipermail/squeak-dev/2011-November/161916....
Le 25 avril 2012 22:49, Bert Freudenberg bert@freudenbergs.de a écrit :
On 25.04.2012, at 13:38, Nicolas Cellier wrote:
Yes, Pharo is a bit ahead, I have a change in Squeak/inbox to align Squeak printing...
Nicolas
Defaulting to be right seems better than being fast ...
- Bert -
Well, push it :)
- Bert -
On 25.04.2012, at 14:01, Nicolas Cellier wrote:
http://lists.squeakfoundation.org/pipermail/squeak-dev/2011-November/161915.... http://lists.squeakfoundation.org/pipermail/squeak-dev/2011-November/161916....
Le 25 avril 2012 22:49, Bert Freudenberg bert@freudenbergs.de a écrit :
On 25.04.2012, at 13:38, Nicolas Cellier wrote:
Yes, Pharo is a bit ahead, I have a change in Squeak/inbox to align Squeak printing...
Nicolas
Defaulting to be right seems better than being fast ...
- Bert -
On Wed, Apr 25, 2012 at 02:35:45PM -0700, Bert Freudenberg wrote:
On 25.04.2012, at 14:01, Nicolas Cellier wrote:
Le 25 avril 2012 22:49, Bert Freudenberg bert@freudenbergs.de a ?crit :
On 25.04.2012, at 13:38, Nicolas Cellier wrote:
Yes, Pharo is a bit ahead, I have a change in Squeak/inbox to align Squeak printing...
Nicolas
Defaulting to be right seems better than being fast ...
- Bert -
http://lists.squeakfoundation.org/pipermail/squeak-dev/2011-November/161915.... http://lists.squeakfoundation.org/pipermail/squeak-dev/2011-November/161916....
Well, push it :)
- Bert -
+1
Dave
Bert,
On 25 Apr 2012, at 22:28, Bert Freudenberg wrote:
If you use storeString instead of asString it will be the same. E.g.
(10 raisedTo: -100) asFloat storeString ==> '1.0e-100'
Strange, Float>>#printOn:base: uses #absPrintOn:base: in Squeak, while it uses #absPrintExactlyOn:base: in Pharo.
Did Squeak make that choice for speed reasons then ?
Sven
Le 25 avril 2012 22:38, Sven Van Caekenberghe sven@beta9.be a écrit :
Bert,
On 25 Apr 2012, at 22:28, Bert Freudenberg wrote:
If you use storeString instead of asString it will be the same. E.g.
(10 raisedTo: -100) asFloat storeString ==> '1.0e-100'
Strange, Float>>#printOn:base: uses #absPrintOn:base: in Squeak, while it uses #absPrintExactlyOn:base: in Pharo.
Did Squeak make that choice for speed reasons then ?
Sven
Yes, I presume main reason was speed, and still is for adoption delay.
Nicolas
squeak-dev@lists.squeakfoundation.org