[BUG] Inconsistent float soustraction

Sebastian Sastre ssastre at seaswork.com
Sun Feb 17 15:40:05 UTC 2008


Hi Cédrick,

	if you need to operate with exact precision just don't trust floats. Use ScaledDecimals instead. In Squeak ScaledDecimals are implemented with the fraction so it's matematically stronger than floats. Use floats at presentation or user interface time and evade them at domain model.

	cheers,

Sebastian Sastre


 

> -----Mensaje original-----
> De: squeak-dev-bounces at lists.squeakfoundation.org 
> [mailto:squeak-dev-bounces at lists.squeakfoundation.org] En 
> nombre de cdrick
> Enviado el: Domingo, 17 de Febrero de 2008 11:42
> Para: The general-purpose Squeak developers list
> Asunto: [BUG] Inconsistent float soustraction
> 
> Hi,
> 
> I noticed in my image (damien last beta so 3.10 - windows XP and
> Vista) that I have a strange bug when soustracting floats
> successively. Here is how I reproduce it in a workspace:
> 
> 1 - 0.2 -0.05 -0.3 = 0.45 "true"
> 1 - 0.2 -0.05 -0.3 -0.1= 0.35  "true"
> 1 - 0.2 -0.05 -0.3 -0.1 - 0.10= 0.25  "*****false*****"
> 1 - 0.2 -0.05 -0.3 -0.1 - 0.10= 0.24999999999999995   true
> 
> or again:
> 1 - 0.1 = 0.9  true
> 1 - 0.1 - 0.1 = 0.8 true
> 1 - 0.1 - 0.1 - 0.1 = 0.7 false
> 
> 
> Can somebody explain that or is it a bug ? I don't know yet if it's
> specific to my image, so does other have the same behavior?
> I can force the rounding of the result but find it strange.
> 
> Cédrick
> 




More information about the Squeak-dev mailing list