oscbyspro / Numberick

An arithmagick overhaul in Swift
Apache License 2.0
15 stars 3 forks source link

Req. `update(_:)` method #113

Open oscbyspro opened 1 year ago

oscbyspro commented 1 year ago

I'm working on some prime stuff, and I need a squareRoot(of:) method that doesn't rely on floating points. So, I use Newton's method. It's relatively fast and super simple. In doing so, I noticed that the implementation for core integers and what I might write for UIntXL is similar. UIntXL has an update(_:) method for in-place assignments. If all binary integers had this method, then perhaps I could make squareRoot(of:) and friends generic over all binary integer.

oscbyspro commented 1 year ago

As a side note, I can get a decent initial approximation as I've already added leadingZeroBitCount to NBKBinaryInteger.

oscbyspro commented 1 year ago

Although, in this particular case it might not matter because the assignment is followed by division :man_shrugging: