[Newbies] Re: is 0.1 a Float or a ScaledDecimal ?
cdrick
cdrick65 at gmail.com
Wed Feb 20 16:32:22 UTC 2008
> What you desire is admirable but no longer practical as it would break a great
> many existing programs.
Yep, that's a BIG problem :-)
[snip]
> 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.
Interesting, Thanks :)
>
> 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.
>
This wasn't my point. I was modeling a ownership degree as 0.1
multiple, so that's ok if I use integer (1 to 10) or scaled decimal
instead of floats. I just said I found weird (even if correct) 0.1
asFraction couldn't return 1/10 but that's ok... I don't especially
want to push that, just wanted some insights and you gave me some...
so Thank you :-)
Also, I didn't know 0.1234s4 notation before so having a unit test
failing was finally a good thing. I was testing a method called
remainingWeight (so basically 1 - SumOfAllSubsetWeight, hence the test
of *egality*... between floats)).
Cédrick
More information about the Beginners
mailing list