Skip to content

Commit

Permalink
[NBKCoreKit] Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
oscbyspro committed Nov 22, 2023
1 parent 753c0d7 commit 28a3c4e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions Sources/NBKCoreKit/Private/NBKProperBinaryInteger+Roots.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ extension NBK.ProperBinaryInteger where Integer: NBKUnsignedInteger {
}
//=--------------------------------------=
var guess: (Integer,Integer)
guess.0 = Integer(digit: 1) << ((power.bitWidth &- power.leadingZeroBitCount) &>> 1 &+ 1)
guess.1 = Integer(digit: 1) << ((power.bitWidth &- power.leadingZeroBitCount) &>> 1 &+ 1)
//=--------------------------------------=
repeat {

guess.1 = guess.0
guess.0 = power
guess.0 /= guess.1
guess.0 += guess.1
guess.0 >>= Int.one
guess.0 = guess.1
guess.1 = power
guess.1 /= guess.0
guess.1 += guess.0
guess.1 >>= Int.one

} while guess.0 < guess.1
return (guess.1)
} while guess.1 < guess.0
return (guess.0)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ final class NBKProperBinaryIntegerTestsOnRoots: XCTestCase {
NBKAssertSquareRoot( Int32.max, 0000046340)
NBKAssertSquareRoot( Int64.max, 3037000499)

NBKAssertSquareRoot(UInt8 .max, UInt8 .max >> 4)
NBKAssertSquareRoot(UInt16.max, UInt16.max >> 8)
NBKAssertSquareRoot(UInt8 .max, UInt8 .max >> 04)
NBKAssertSquareRoot(UInt16.max, UInt16.max >> 08)
NBKAssertSquareRoot(UInt32.max, UInt32.max >> 16)
NBKAssertSquareRoot(UInt64.max, UInt64.max >> 32)

for base in (0 as Int64) ... (100 as Int64) {
for base in 0 as Int64 ..< 144 {
for power in (base * base) ..< (base + 1) * (base + 1) {
NBKAssertSquareRoot(power, base)
NBKAssertSquareRoot(power, base)
}
}
}
Expand Down

0 comments on commit 28a3c4e

Please sign in to comment.