> [...] and if you write 1.3, the object that represents that number
> is not going to be an instance of float but of scaledecimal or
> fraction or whatever, but not float...

That only solves the issue of representing literals because:


> and all operations are made with exact representation.



cannot be done for all operations: obvious ones like square root, log,
sin, etc and less obvious ones like #squared where you run out of
enough bits to maintain precision (in fixed-width implementations).

not really... root, log, sin, etc could be messages that only inexact numbers know how to answer , so you want "2 sqrt",� do "2 asFloat sqrt", but for +, *, /, etc. they work as expected.
We can also have better representations for number like pi. Why pi is instance of Float and not Pi? If pi is instance of Pi, then cos(pi/2) = 0 could be true... just a quick hack:
Pi>>/ aNumber

� ^ Fraction numerator: self denominator: aNumber� "Or maybe an object representing that Pi has been divided/multiplied, etc

Fraction>>cos

�^ numerator cosDividedWith: denominator

Pi>>cosDividedWith: denominator

�^denominator = 2 ifTrue: [ 0 ] ifFalse: [ ... ]

and so on




R
-


_______________________________________________
Pharo-project mailing list
Pharo-project@lists.gforge.inria.fr
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project