[Newbies] Re: is 0.1 a Float or a ScaledDecimal ?

Louis LaBrunda Lou at Keystone-Software.com
Wed Feb 20 14:53:26 UTC 2008

>I have another interrogation. Please take it as a student/newbie
>whatever question.
>I think 0.1 should be considered as a ScaledDecimal so that we could
>write 0.1 asFraction and have 1/10...

What you desire is admirable but no longer practical as it would break a great
many existing programs.  In the begriming data types were closely tied to what
the hardware supported.  Most early computers supported integers (small
integers, not the long kind that we have in Smalltalk) and maybe some form of
floating point numbers and some form of decimals.  Things weren't very standard
between different manufactures computers.  After a while, computers supported
integers, floating point numbers and IBM mainframes had packed decimal numbers
(in the hardware) that are a lot like ScaledDecimal numbers, they were used a
lot in COBOL.

So, most languages took 0.1 to be a floating point number.  When Smalltalk came
along, it followed in that tradition.  Smalltalk added 0.1s1as a ScaledDecimal
number and 1/10 as a fraction.  They are both implemented as a mix of software
and hardware and not mapped directly to hardware.

Lastly, I would point out that in Smalltalk when you say 1/10 you get an
instance of a fraction and not an instruction to divide 1 by 10.  Therefore, you
don't need to say 0.1 asFraction or 0.1s1 asFraction to get 1/10 as an instance
of Fraction.

Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:Lou at Keystone-Software.com http://www.Keystone-Software.com

More information about the Beginners mailing list