[Squeakland] A question about fractions and large integers in Etoys

Scott Wallace scott.wallace at squeakland.org
Wed Jan 14 13:43:10 PST 2004


Hi, Ken,

Internally, numbers are stored in whatever form their calculation 
yields -- thus, if you store 1/3 into a variable, it will be stored 
internally as a Fraction object representing 1/3 exactly, but it will 
be *displayed* as 0.3 or 0.33 or 0.333 or whatever the prevailing 
precision specification is for any given readou.  The etoy system 
provides standard defaults for the number of decimal places to show, 
and allows the user to override those for any particular readout. 
Acceptable values range from 0 to 7 decimal places.

Concerning hugely large numbers, well, we don't actually have an 
articulated policy for how to display them.  Rather, there are a 
variety of factors that contribute to the emergent behavior.

Most of the time, in fact, it turns out that such numbers are 
actually displayed incorrectly -- a bug that I just discovered (to my 
dismay) when checking to make sure what the current behavior is.  The 
bug can occur whenever the printString of a number results in a 
string containing an "e" (standing for "times ten to the power"), 
because the render-with-precision code neglects to take the 
possibility of an "e" into account.  This has to get fixed!

Realistically, I think that once the bug gets fixed, 
out-of-normal-range numbers will get displayed using the e-notation.

However there's a further problem, which is that many 
LargePositiveIntegers (which result for example from most factorial 
computations) cannot be successfully converted to floats for compact 
printout.  For example,

"170 factorial asFloat" prints out as  "7.257415615308e306"

but

"171 factorial asFloat" prints out as "Infinity".

Anyway.  For the purposes of your paper, I don't think Squeak etoys 
have much to contribute on this topic.  Our etoy system operates as a 
rather thin kid-oriented veneer atop the vast programmer-oriented 
foundation that is Squeak itself, and it is Squeak itself that 
provides most of the underlying support, including all of the 
boundary-condition and extreme-value handling that has not been 
explicitly overridden for the benefit of etoys.

I regret that it took this long for someone in the Squeak community 
to reply to you.

Cheers,

   -- Scott

At 12:13 PM +0000 1/9/04, Ken Kahn wrote:
>I understand that Squeak supports very large integers and exact
>fractions (as opposed to approximate floating point numbers). What I
>don't know is if and how this functionality is presented in Etoys. For
>example what happens when you divide 1 by 3? How is the repeated decimal
>expansion displayed? Or is it displayed as 1/3? Or if a child computes
>the factorial of 10000 how are the over 35,000 digits displayed?
>
>Thanks in advance,
>
>-ken kahn
>
>P.S. I'm writing a paper on how these issues are dealt with in ToonTalk
>and am writing the "related work" section.


More information about the Squeakland mailing list