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>) {
44
44
}
45
45
46
46
extension BinaryInteger {
47
- func writeToStdout(radix: Int = 10 ) {
47
+ func writeToStdout() {
48
48
if self == (0 as Self) {
49
49
print( " 0 " , terminator: " " )
50
50
return
51
51
}
52
-
52
+
53
53
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
59
55
}
60
56
let isNegative = Self.isSigned && self < (0 as Self)
61
57
var value = magnitude
@@ -70,7 +66,7 @@ extension BinaryInteger {
70
66
var index = buffer.count - 1
71
67
while value != 0 {
72
68
let (quotient, remainder) =
73
- value.quotientAndRemainder(dividingBy: Magnitude(radix ))
69
+ value.quotientAndRemainder(dividingBy: Magnitude(10 ))
74
70
buffer[index] = _ascii(UInt8(truncatingIfNeeded: remainder))
75
71
index -= 1
76
72
value = quotient
You can’t perform that action at this time.
0 commit comments