Skip to content

Commit

Permalink
[stdlib] Expand integer conversion comment
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickPijnappel committed Oct 19, 2020
1 parent 87c177c commit 8ecd884
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion stdlib/public/core/Integers.swift
Expand Up @@ -3010,7 +3010,10 @@ extension FixedWidthInteger {
let minBitWidth = source.significandWidth
let isExact = (minBitWidth <= exponent)
let bitPattern = source.significandBitPattern
// Determine the number of meaningful bits in the significand bit pattern.
// Determine the actual number of fractional significand bits.
// `Source.significandBitCount` would not reflect the actual number of
// fractional significand bits if `Source` is not a fixed-width floating-point
// type; we can compute this value as follows if `source` is finite:
let bitWidth = minBitWidth &+ bitPattern.trailingZeroBitCount
let shift = exponent - Source.Exponent(bitWidth)
// Use `Self.Magnitude` to prevent sign extension if `shift < 0`.
Expand Down

0 comments on commit 8ecd884

Please sign in to comment.