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" | 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: #/.!
packages@lists.squeakfoundation.org