[squeak-dev] The Trunk: Kernel-nice.1461.mcz
Nicolas Cellier
nicolas.cellier.aka.nice at gmail.com
Tue Apr 26 11:29:16 UTC 2022
Le mar. 26 avr. 2022 à 11:22, <commits at source.squeak.org> a écrit :
> Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
> http://source.squeak.org/trunk/Kernel-nice.1461.mcz
>
> ==================== Summary ====================
>
> Name: Kernel-nice.1461
> Author: nice
> Time: 26 April 2022, 11:22:41.16552 am
> UUID: 45d507fb-8cd8-164a-94a7-66d354f4aeaa
> Ancestors: Kernel-nice.1460
>
> Provide a more robust version of Complex divideSecureBy:, at least passing
> the new tests.
>
> =============== Diff against Kernel-nice.1460 ===============
>
> Item was changed:
> ----- Method: Complex>>divideSecureBy: (in category 'arithmetic') -----
> divideSecureBy: anObject
> "Answer the result of dividing receiver by aNumber"
> " Both operands are scaled to avoid arithmetic overflow. This
> algorithm
> works for a wide range of values, but it requires six
> divisions.
> #divideFastAndSecureBy: is also quite good, but it uses only 3
> divisions.
> + Note: #reciprocal uses #/ for division"
> - Note: #reciprocal uses #/ for devision"
>
We can remove above note once #/ fallbacks to divideSecureBy: as posted in
inbox.
>
> | s ars ais brs bis newReal newImaginary |
> anObject isComplex ifTrue:
> + [s := anObject real abs max: anObject imaginary abs.
> - [s := anObject real abs + anObject imaginary abs.
> ars := self real / s.
> ais := self imaginary / s.
> brs := anObject real / s.
> bis := anObject imaginary / s.
> s := brs squared + bis squared.
> + brs := brs / s.
> + bis := bis / s.
>
> + newReal := ars*brs + (ais*bis).
> + newImaginary := ais*brs - (ars*bis).
> - newReal := ars*brs + (ais*bis) /s.
> - newImaginary := ais*brs - (ars*bis)/s.
> ^ Complex real: newReal imaginary: newImaginary].
> ^ anObject adaptToComplex: self andSend: #/.!
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220426/27e1c373/attachment.html>
More information about the Squeak-dev
mailing list
|