Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions stdlib/public/core/IntegerParsing.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ internal func _parseAsciiAsUIntMax(
else { return nil }
// Disallow < 0.
if hasMinus && result != 0 { return nil }
// Return.

return result
}

Expand All @@ -97,12 +97,12 @@ internal func _parseAsciiAsIntMax(
if utf16.isEmpty { return nil }
// Parse (optional) sign.
let (digitsUTF16, hasMinus) = _parseOptionalAsciiSign(utf16)
// Parse digits. +1 for because e.g. Int8's range is -128...127.
// Parse digits. +1 for negatives because e.g. Int8's range is -128...127.
let absValueMax = UIntMax(bitPattern: maximum) + (hasMinus ? 1 : 0)
guard let absValue =
_parseUnsignedAsciiAsUIntMax(digitsUTF16, radix, absValueMax)
else { return nil }
// Return signed result.
// Convert to signed.
return IntMax(bitPattern: hasMinus ? 0 &- absValue : absValue)
}

Expand Down