File tree Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -44,18 +44,14 @@ func printCharacters(_ buf: UnsafeBufferPointer<UInt8>) {
4444}
4545
4646extension BinaryInteger {
47- func writeToStdout(radix: Int = 10 ) {
47+ func writeToStdout() {
4848 if self == (0 as Self) {
4949 print( " 0 " , terminator: " " )
5050 return
5151 }
52-
52+
5353 func _ascii(_ digit: UInt8) -> UInt8 {
54- if digit < 10 {
55- UInt8(( " 0 " as Unicode.Scalar).value) + digit
56- } else {
57- UInt8(( " a" as Unicode.Scalar).value) + (digit - 10)
58- }
54+ UInt8(( " 0 " as Unicode.Scalar).value) + digit
5955 }
6056 let isNegative = Self.isSigned && self < (0 as Self)
6157 var value = magnitude
@@ -70,7 +66,7 @@ extension BinaryInteger {
7066 var index = buffer.count - 1
7167 while value != 0 {
7268 let (quotient, remainder) =
73- value.quotientAndRemainder(dividingBy: Magnitude(radix ))
69+ value.quotientAndRemainder(dividingBy: Magnitude(10 ))
7470 buffer[index] = _ascii(UInt8(truncatingIfNeeded: remainder))
7571 index -= 1
7672 value = quotient
You can’t perform that action at this time.
0 commit comments