Hi Nocolas,<br><br>Thanks for the review.&nbsp; I have not actually used this for arithmetic yet, I added that in a couple of hours before publishing this.&nbsp; Previously this has been used to represent the decimal values that I needed to use to load into a database using a fixed length representation.&nbsp; This need influenced my design quite a bit.&nbsp; However, without arithmetic, it isn&#39;t very useful for many other people (or myself going forward).
<br><br>As to your points;<br><br><div><span class="gmail_quote"><br></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">(-53/10 asFixedDecimal: 2) fractionPart.
</blockquote><div><br>Right.&nbsp; I&nbsp; did not finish adding in all of the protocol that should be added.&nbsp; I will&nbsp; continue to do this over the next few days as I have time.&nbsp; For now, this works:<br><br>(-53/10 asFixedDecimal: 2) fractionPart. -
0.30<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">- why maintaining so many forms in parallel ?<br>&nbsp;&nbsp; Not bug-proof, you happen to update one form not the other...
<br>&nbsp;&nbsp; sign is not handled in part1 nor part2</blockquote><div><br>This is a result of&nbsp; what I was originally using it for, which works pretty well (until I introduce bugs, that is).&nbsp; Keeping the various different forms there does make certain transformations much easier to handle.&nbsp; However, I might take a look at other ways to handle this.&nbsp; (Also, this repository is open, is if anyone wants to add a different representation, they are free to do so).
<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">- negated should create a new instance<br>&nbsp;&nbsp; rather than modifying the number in place
</blockquote><div><br>Yes, that was a bad choice.&nbsp; It is now making a new instance. <br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
- FixedDecimals does not implement hash,<br>&nbsp;&nbsp; therefore cannot be stored in a Dictionary.</blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
&nbsp;&nbsp; Particularly, cannot be stored in a workspace variable.<br>&nbsp;&nbsp; I suggest hash ^self asFraction hash</blockquote><div><br>This is now fixed, as you suggested.&nbsp; Although I may tweak this (is there a good hash tester available for Squeak?)
<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">- likewise, implement all subclassResponsibility</blockquote><div><br>Right.&nbsp; I&#39;m working on that...&nbsp;&nbsp;
</div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;( 5/3) * (5/3 asFixedDecimal: 2).<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;( 2.0s1) * (5/3 asFixedDecimal: 2).
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(5/3 asFixedDecimal: 2) reciprocal.</blockquote><div><br>Fixed.&nbsp; See below.<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
- coercion depends on receiver:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| a b |<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a := (53/10 asFixedDecimal: 2).<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b := 5.3.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ (a+b) class.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(b+a) class. } &quot;is {FixedDecimal . Float}&quot;</blockquote><div>
<br>Hmmm.&nbsp; Yes.&nbsp; I think I want all arithmetic with FixedDecimals to return a FixedDecimal.&nbsp; Looking as ScaledDecimals, I notice that what is returned is consistent with for a given other magnitude, but not always the same.&nbsp; Is there a rational behind which type of number is returned?&nbsp; Is it spelled out in ANSI?
<br>(Also, while checking this, I noticed that .333 does not give you 0.333 but rather 333.&nbsp; I wonder if I&#39;ve coded in a bug like that somewhere else?&nbsp; If the . is the first part of the method or workspace, it just quitely eats it.)
<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">- maybe add another rounding mode in arithmetic (to nearest even...)</blockquote>
<div><br>I might add something like that as time permits.&nbsp; Do you have a use for it? <br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
- create a specific notation for transparent read/write, like 5.30f<br>&nbsp;&nbsp;(requires some easy support in Number class&gt;&gt;readFrom: or NumberParser)</blockquote><div><br>Will do. <br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
 From algebraic point of view, the main concern is that some numbers<br>might not have any reciprocal...<br>Unless the reciprocal is a Fraction, and arithmetic op coerce to Fraction...<br>But, eh, this is just the case of Float:
<br>| f |<br>f := (8872240531573379/9007199254740992) asFloat.<br>f * f reciprocal - 1</blockquote><div><br>Well, this particular number DOES have a reciprocal in FixedDecimals which just happens to be a FixedDecimal.&nbsp; You just have to specify the scale right:
<br>fd _ (8872240531573379/9007199254740992) asFixedDecimal: 53 <br>rfd _ fd reciprocal<br>rfd reciprocal <br>fd * rfd - 1 = 0.00000000000000000000000000000000000000000000000000000<br>That said, there might be some rational numbers that will not have a reciprocal, but I can&#39;t find them.&nbsp; For instance:
<br>fd _ (1/3) asFixedDecimal: 5&nbsp; &quot;= 0.33333&quot;<br>rfd _ fd reciprocal&nbsp; &quot;= 3.00003&quot;<br>fd * rfd - 1&nbsp; &quot;0.00000&quot;<br><br></div>Most of this is now out in SqueakSource.&nbsp; I&#39;ll do some more as time permits.&nbsp; (Also, all of these changes now have tests, too).
<br><br>Thanks,<br>Chris<br></div>