Skip to content

[stdlib] Fix comments #777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 26, 2015
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