In the Playground, if I type in 0.1s and then "Print it", I get the following output: *0.1s1* What does the *s1* stand for? Why doesn't it simply print *s*?
The number after the s is the scale of the ScaledDecimal. E.g. If you write 0.1s3 it means you instantiate a ScaledDecimal that is 0.001 So it sems that printOn: in ScaledDecimal is being "explicit" as it prints 1 when other dialects don't. Regards, Esteban A. Maringolo On Thu, Jan 30, 2020 at 2:07 PM Richard Kenneth Eng <horrido.hobbies@gmail.com> wrote:
In the Playground, if I type in
0.1s
and then "Print it", I get the following output:
0.1s1
What does the s1 stand for? Why doesn't it simply print s?
Errata:
E.g. If you write 0.1s3 it means you instantiate a ScaledDecimal that is 0.001
I meant: 0.1s3 = 0.100 Esteban A. Maringolo On Thu, Jan 30, 2020 at 2:28 PM Esteban Maringolo <emaringolo@gmail.com> wrote:
The number after the s is the scale of the ScaledDecimal.
E.g. If you write 0.1s3 it means you instantiate a ScaledDecimal that is 0.001
So it sems that printOn: in ScaledDecimal is being "explicit" as it prints 1 when other dialects don't.
Regards,
Esteban A. Maringolo
On Thu, Jan 30, 2020 at 2:07 PM Richard Kenneth Eng <horrido.hobbies@gmail.com> wrote:
In the Playground, if I type in
0.1s
and then "Print it", I get the following output:
0.1s1
What does the s1 stand for? Why doesn't it simply print s?
Hi Richard For âPrint itâ representations of objects, you can browser the #printOn: method of the class of that object. For ScaledDecimal, it is: printOn: aStream "Append an approximated representation of the receiver on aStream. Use prescribed number of digits after decimal point (the scale) using a rounding operation if not exact" self printOn: aStream showingDecimalPlaces: scale. "Append a scale specification so that the number can be recognized as a ScaledDecimal" aStream nextPut: $s; print: scale. Vince
participants (3)
-
Esteban Maringolo -
Richard Kenneth Eng -
Vince Refiti