2009/7/8 Ignacio Vivona <[email protected]>:
> The question is why do you want Floats to be the default implementation of
> reals instead of ScaledDecimals?
>

Ignacio,
This is a good question, and I don't have the answer. It would be
worth experimenting.
Newspeak project wanted to follow this road AFAIK, unfortunately they
died before they did it, so we won't benefit from their work...
Michael proposed this earlier in the thread.

Unfortunately, current ScaledDecimal implementations will reserve more
surprises like 0.5s1 * 0.5s1 -> 0.3s1
We should better have the number of decimal digits undefined 0.5s*0.5s -> 0.25s
But still limit number of printed characters 1.0s / 3.0s -> 0.3333333s....

Or maybe use a special notation for repeated pattern
1.0s / 3.0s -> 0.3333333(3)
1.0s / 7.0s -> 0.(142857)


> On Wed, Jul 8, 2009 at 4:29 PM, Igor Stasenko <[email protected]> wrote:
>>
>> 2009/7/8 Hernan Wilkinson <[email protected]>:
>> > it was just an example where you can "bind" as "late" as possible a
>> > combination of symbols with its value... I like late binding :-) in this
>> > example allows you to get rigth results... and of course
>> > cosPiHalved is not the same as "a/b cos" where a is bound to pi and b to
>> > 2... it is not only for literals.
>> >
>>
>> If you like the late binding, and if you are using a set of functions
>> which having no side effects , then
>> you can, instead of computing the result , store the numerical
>> operations (in same fashion as Fraction stores division) and compute
>> the exact value(s) only when you really need them.
>> Then you can bring in the power of mathematical apparatus/trigonometry
>> rules and use them at full scale.
>>
>> Think, how many things we can add (in parallel to Fraction)
>> SquaredNumber
>> SquaredRootNumber
>> CosFn
>> SinFn
>> TanFn
>> PiFraction
>> and so on.. limited only by your own limits/knowledge...
>>
>> But again, all of this stuff is more related to predicting than exact
>> computing , which is happens to be inexact because of hardware
>> limitations :)
>>
>> > On Wed, Jul 8, 2009 at 3:59 PM, Igor Stasenko <[email protected]>
>> > wrote:
>> >>
>> >> 2009/7/8 Hernan Wilkinson <[email protected]>:
>> >> >
>> >> >>
>> >> >>
>> >> >> > [...] 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
>> >> >
>> >>
>> >>
>> >> don't forget to add
>> >> Pi>>mantisOfLength: numBits
>> >>
>> >> to compute the Pi up to given precision. :)
>> >>
>> >>
>> >> But your examples is not about computing a result, but rather
>> >> predicting
>> >> it.
>> >> So why bother writing so much stuff , while you can just implement :
>> >>
>> >> Number>>cosPiHalved
>> >>  ^ 0
>> >>
>> >> :)
>> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> R
>> >> >> -
>> >> >>
>> >> >>
>> >> >> _______________________________________________
>> >> >> Pharo-project mailing list
>> >> >> [email protected]
>> >> >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>> >> >
>> >> >
>> >> > _______________________________________________
>> >> > Pharo-project mailing list
>> >> > [email protected]
>> >> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Best regards,
>> >> Igor Stasenko AKA sig.
>> >>
>> >> _______________________________________________
>> >> Pharo-project mailing list
>> >> [email protected]
>> >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>> >
>> > _______________________________________________
>> > Pharo-project mailing list
>> > [email protected]
>> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>> >
>>
>>
>>
>> --
>> Best regards,
>> Igor Stasenko AKA sig.
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [email protected]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
> --
> Hope is for sissies (Gregory House, M.D.)
>
> _______________________________________________
> Pharo-project mailing list
> [email protected]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>

_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to