<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2015-05-02 18:27 GMT+02:00 <span dir="ltr"><<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">A new version of Kernel was added to project The Inbox:<br>
<a href="http://source.squeak.org/inbox/Kernel-mtf.924.mcz" target="_blank">http://source.squeak.org/inbox/Kernel-mtf.924.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Kernel-mtf.924<br>
Author: mtf<br>
Time: 2 May 2015, 12:26:05.675 pm<br>
UUID: 7f688860-5202-4c0d-8ece-8723fe7317d6<br>
Ancestors: Kernel-nice.923<br>
<br>
Copied Number >> #round: from Pharo. One of 3 methods needed to make the Artefact pdf library work on squeak: <a href="https://sites.google.com/site/artefactpdf/" target="_blank">https://sites.google.com/site/artefactpdf/</a><br>
<br>
=============== Diff against Kernel-nice.923 ===============<br>
<br>
Item was added:<br>
+ ----- Method: Float>>round: (in category 'truncation and round off') -----<br>
+ round: numberOfWishedDecimal<br>
+ "only leave a fixed amount of decimal"<br>
+ "10.12345 round: 2 => 10.12"<br>
+<br>
+ | v |<br>
+ v := 10 raisedTo: numberOfWishedDecimal.<br>
+ ^ ((self * v) rounded / v) asFloat<br>
+ !<br>
<br></blockquote><div><br></div><div>self assert: (Float fmax round: 2) = Float fmax.<br><br></div><div>It's probably not very important for artefact, but if this method has a wider usage than artefact, then it should better be robust to overflow...<br> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Item was added:<br>
+ ----- Method: Fraction>>round: (in category 'truncation and round off') -----<br>
+ round: numberOfWishedDecimal<br>
+ ^self asFloat round: numberOfWishedDecimal!<br>
<br></blockquote><div><br></div><div>Transforming exact arithmetic into inexact Float sounds like heresy to me ;)<br></div><div>That's a questionable choice.<br></div><div>Why this cult to Float would be necessary here?<br> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Item was added:<br>
+ ----- Method: Integer>>round: (in category 'truncation and round off') -----<br>
+ round: numberOfWishedDecimal<br>
+ ^self!<br>
<br>
Item was added:<br>
+ ----- Method: Number>>round: (in category 'truncation and round off') -----<br>
+ round: numberOfWishedDecimal<br>
+ self subclassResponsibility!<br>
<br>
<br>
</blockquote></div>If it's subclass responsibility, then it must be implemented in ScaledDecimal.<br></div><div class="gmail_extra">This is not necessary in Pharo, because ScaledDecimal has been moved under Fraction, but it is in Squeak.<br></div><div class="gmail_extra">I'd rather see Float implementation moved up (without the asFloat) and Float invoking super asFloat...<br><br></div><div class="gmail_extra">I didn't check artefact, but I suspect that the usage is just to printShowingMaxDecimals: numberOfWishedDecimal, which would make the whole method moot.<br><br></div><div class="gmail_extra">Nicolas<br></div></div>