Skip to content

Commit 43a9a80

Browse files
committed
[embedded] Hardcode radix=10 in embedded print()
1 parent abeecb3 commit 43a9a80

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

stdlib/public/core/EmbeddedPrint.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,14 @@ func printCharacters(_ buf: UnsafeBufferPointer<UInt8>) {
4444
}
4545
4646
extension 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

0 commit comments

Comments
 (0)