<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le mar. 26 avr. 2022 à 11:22, <<a href="mailto:commits@source.squeak.org">commits@source.squeak.org</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Nicolas Cellier uploaded a new version of Kernel to project The Trunk:<br>
<a href="http://source.squeak.org/trunk/Kernel-nice.1461.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/trunk/Kernel-nice.1461.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Kernel-nice.1461<br>
Author: nice<br>
Time: 26 April 2022, 11:22:41.16552 am<br>
UUID: 45d507fb-8cd8-164a-94a7-66d354f4aeaa<br>
Ancestors: Kernel-nice.1460<br>
<br>
Provide a more robust version of Complex divideSecureBy:, at least passing the new tests.<br>
<br>
=============== Diff against Kernel-nice.1460 ===============<br>
<br>
Item was changed:<br>
  ----- Method: Complex>>divideSecureBy: (in category 'arithmetic') -----<br>
  divideSecureBy: anObject<br>
        "Answer the result of dividing receiver by aNumber"<br>
        " Both operands are scaled to avoid arithmetic overflow. This algorithm <br>
          works for a wide range of values, but it requires six divisions.  <br>
          #divideFastAndSecureBy:  is also quite good, but it uses only 3 divisions.<br>
+          Note: #reciprocal uses #/ for division"<br>
-          Note: #reciprocal uses #/ for devision"<br></blockquote><div>We can remove above note once #/ fallbacks to divideSecureBy: as posted in inbox. <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
        | s ars ais brs bis newReal newImaginary |<br>
        anObject isComplex ifTrue:<br>
+               [s := anObject real abs max: anObject imaginary abs.<br>
-               [s := anObject real abs + anObject imaginary abs.<br>
                 ars := self real / s.<br>
                 ais := self imaginary / s.<br>
                 brs := anObject real / s.<br>
                 bis := anObject imaginary / s.<br>
                 s := brs squared + bis squared.<br>
+                brs := brs / s.<br>
+                bis := bis / s.<br>
<br>
+               newReal := ars*brs + (ais*bis).<br>
+               newImaginary := ais*brs - (ars*bis).<br>
-               newReal := ars*brs + (ais*bis) /s.<br>
-               newImaginary := ais*brs - (ars*bis)/s.<br>
                ^ Complex real: newReal imaginary: newImaginary].<br>
        ^ anObject adaptToComplex: self andSend: #/.!<br>
<br>
<br>
</blockquote></div></div>