@@ -809,8 +809,8 @@ def assignmentOperatorComment(operator, fixedWidth):
809
809
def overflowOperationComment( operator) :
810
810
comments = {
811
811
'+ ': """ \
812
- /// Returns the sum of this value and the given value along with a flag
813
- /// indicating whether overflow occurred in the operation.
812
+ /// Returns the sum of this value and the given value, along with a Boolean
813
+ /// value indicating whether overflow occurred in the operation.
814
814
///
815
815
/// - Parameter rhs: The value to add to this value.
816
816
/// - Returns: A tuple containing the result of the addition along with a
@@ -821,32 +821,34 @@ def overflowOperationComment(operator):
821
821
/// and `rhs`.
822
822
""" ,
823
823
'- ': """ \
824
- /// Returns the difference of this value and the given value along with a
825
- /// flag indicating whether overflow occurred in the operation.
824
+ /// Returns the difference obtained by subtracting the given value from this
825
+ /// value, along with a Boolean value indicating whether overflow occurred in
826
+ /// the operation.
826
827
///
827
828
/// - Parameter rhs: The value to subtract from this value.
828
829
/// - Returns: A tuple containing the result of the subtraction along with a
829
- /// flag indicating whether overflow occurred. If the `overflow` component
830
- /// is `false`, the `partialValue` component contains the entire
831
- /// difference. If the `overflow` component is `true`, an overflow
832
- /// occurred and the `partialValue` component contains the truncated
833
- /// result of `rhs` subtracted from this value.
830
+ /// Boolean value indicating whether overflow occurred. If the `overflow`
831
+ /// component is `false`, the `partialValue` component contains the entire
832
+ /// difference. If the `overflow` component is `true`, an overflow occurred
833
+ /// and the `partialValue` component contains the truncated result of `rhs`
834
+ /// subtracted from this value.
834
835
""" ,
835
836
'* ': """ \
836
- /// Returns the product of this value and the given value along with a flag
837
- /// indicating whether overflow occurred in the operation.
837
+ /// Returns the product of this value and the given value, along with a
838
+ /// Boolean value indicating whether overflow occurred in the operation.
838
839
///
839
840
/// - Parameter rhs: The value to multiply by this value.
840
841
/// - Returns: A tuple containing the result of the multiplication along with
841
842
/// a Boolean value indicating whether overflow occurred. If the `overflow`
842
843
/// component is `false`, the `partialValue` component contains the entire
843
- /// product. If the `overflow` component is `true`, an overflow
844
- /// occurred and the `partialValue` component contains the truncated
845
- /// product of this value and `rhs`.
844
+ /// product. If the `overflow` component is `true`, an overflow occurred and
845
+ /// the `partialValue` component contains the truncated product of this
846
+ /// value and `rhs`.
846
847
""" ,
847
848
'/ ': """ \
848
- /// Returns the quotient of dividing this value by the given value along with
849
- /// a flag indicating whether overflow occurred in the operation.
849
+ /// Returns the quotient obtained by dividing this value by the given value,
850
+ /// along with a Boolean value indicating whether overflow occurred in the
851
+ /// operation.
850
852
///
851
853
/// Dividing by zero is not an error when using this method. For a value `x`,
852
854
/// the result of `x.dividedReportingOverflow(by: 0)` is `(x, true)`.
@@ -856,22 +858,24 @@ def overflowOperationComment(operator):
856
858
/// Boolean value indicating whether overflow occurred. If the `overflow`
857
859
/// component is `false`, the `partialValue` component contains the entire
858
860
/// quotient. If the `overflow` component is `true`, an overflow occurred
859
- /// and the `partialValue` component contains the truncated quotient.
861
+ /// and the `partialValue` component contains either the truncated quotient
862
+ /// or, if the quotient is undefined, the dividend.
860
863
""" ,
861
864
'% ': """ \
862
- // FIXME(integers): the comment is for division instead of remainder
863
- /// Returns the remainder of dividing this value by the given value along
864
- /// with a flag indicating whether overflow occurred in the operation.
865
+ /// Returns the remainder after dividing this value by the given value, along
866
+ /// with a Boolean value indicating whether overflow occurred during division.
865
867
///
866
868
/// Dividing by zero is not an error when using this method. For a value `x`,
867
- /// the result of `x.dividedReportingOverflow(by: 0)` is `(x, true)`.
869
+ /// the result of `x.remainderReportingOverflow(dividingBy: 0)` is
870
+ /// `(x, true)`.
868
871
///
869
872
/// - Parameter rhs: The value to divide this value by.
870
- /// - Returns: A tuple containing the result of the division along with a
873
+ /// - Returns: A tuple containing the result of the operation along with a
871
874
/// Boolean value indicating whether overflow occurred. If the `overflow`
872
875
/// component is `false`, the `partialValue` component contains the entire
873
- /// quotient. If the `overflow` component is `true`, an overflow occurred
874
- /// and the `partialValue` component contains the truncated quotient.
876
+ /// remainder. If the `overflow` component is `true`, an overflow occurred
877
+ /// during division and the `partialValue` component contains either the
878
+ /// entire remainder or, if the remainder is undefined, the dividend.
875
879
""" ,
876
880
}
877
881
return comments[ operator]
@@ -896,15 +900,15 @@ def unsafeOperationComment(operator):
896
900
/// - Returns: The sum of this value and `rhs`.
897
901
""" ,
898
902
'- ': """ \
899
- /// Returns the difference of this value and the given value without checking
900
- /// for arithmetic overflow.
903
+ /// Returns the difference obtained by subtracting the given value from this
904
+ /// value without checking for arithmetic overflow.
901
905
///
902
906
/// If an arithmetic overflow occurs, the behavior is undefined. Use this
903
907
/// function only to avoid the cost of overflow checking when you are sure
904
908
/// that the operation won't overflow.
905
909
///
906
910
/// - Parameter rhs: The value to subtract from this value.
907
- /// - Returns: The difference of this value and `rhs`.
911
+ /// - Returns: The result of subtracting `rhs` from this value .
908
912
""" ,
909
913
'* ': """ \
910
914
/// Returns the product of this value and the given value without checking
@@ -915,18 +919,18 @@ def unsafeOperationComment(operator):
915
919
/// that the operation won't overflow.
916
920
///
917
921
/// - Parameter rhs: The value to multiply by this value.
918
- /// - Returns: The difference of this value and `rhs`.
922
+ /// - Returns: The product of this value and `rhs`.
919
923
""" ,
920
924
'/ ': """ \
921
- /// Returns the quotient of dividing this value by the given value without
922
- /// checking for arithmetic overflow.
925
+ /// Returns the quotient obtained by dividing this value by the given value
926
+ /// without checking for arithmetic overflow.
923
927
///
924
928
/// If an arithmetic overflow occurs, the behavior is undefined. Use this
925
929
/// function only to avoid the cost of overflow checking when you are sure
926
930
/// that the operation won't overflow.
927
931
///
928
932
/// - Parameter rhs: The value to divide this value by.
929
- /// - Returns: The quotient of dividing this value by `rhs`.
933
+ /// - Returns: The result of dividing this value by `rhs`.
930
934
""" ,
931
935
}
932
936
return comments[ operator]
@@ -2084,7 +2088,7 @@ public protocol FixedWidthInteger :
2084
2088
/// `-(2 ** (bitWidth - 1))` through `(2 ** (bitWidth - 1)) - 1`. For example,
2085
2089
/// the `Int8` type has a `bitWidth` value of 8 and can store any integer in
2086
2090
/// the range `-128...127`.
2087
- static var bitWidth : Int { get }
2091
+ static var bitWidth: Int { get }
2088
2092
2089
2093
/// The maximum representable integer in this type.
2090
2094
///
@@ -2112,10 +2116,10 @@ ${overflowOperationComment(x.operator)}
2112
2116
///
2113
2117
/// Use this method to calculate the full result of a product that would
2114
2118
/// otherwise overflow. Unlike traditional truncating multiplication, the
2115
- /// `multipliedFullWidth(by:)` method returns a tuple
2116
- /// containing both the `high` and `low` parts of the product of this value and
2117
- /// `other`. The following example uses this method to multiply two `UInt8`
2118
- /// values that normally overflow when multiplied:
2119
+ /// `multipliedFullWidth(by:)` method returns a tuple containing both the
2120
+ /// `high` and `low` parts of the product of this value and `other`. The
2121
+ /// following example uses this method to multiply two `UInt8` values that
2122
+ /// normally overflow when multiplied:
2119
2123
///
2120
2124
/// let x: UInt8 = 100
2121
2125
/// let y: UInt8 = 20
@@ -2136,20 +2140,18 @@ ${overflowOperationComment(x.operator)}
2136
2140
/// - Returns: A tuple containing the high and low parts of the result of
2137
2141
/// multiplying this value and `other`.
2138
2142
func multipliedFullWidth( by other: Self ) -> ( high: Self , low: Self . Magnitude )
2139
- // FIXME(integers): figure out how to return DoubleWidth<Self>
2140
2143
2141
- /// Returns a tuple containing the quotient and remainder of dividing the
2142
- /// given value by this value.
2144
+ /// Returns a tuple containing the quotient and remainder obtained by dividing
2145
+ /// the given value by this value.
2143
2146
///
2144
2147
/// The resulting quotient must be representable within the bounds of the
2145
- /// type. If the quotient of dividing `dividend` by this value is too large
2146
- /// to represent in the type, a runtime error may occur.
2148
+ /// type. If the quotient is too large to represent in the type, a runtime
2149
+ /// error may occur.
2147
2150
///
2148
2151
/// - Parameter dividend: A tuple containing the high and low parts of a
2149
- /// double-width integer. The `high` component of the value carries the
2150
- /// sign, if the type is signed.
2151
- /// - Returns: A tuple containing the quotient and remainder of `dividend`
2152
- /// divided by this value.
2152
+ /// double-width integer.
2153
+ /// - Returns: A tuple containing the quotient and remainder obtained by
2154
+ /// dividing `dividend` by this value.
2153
2155
func dividingFullWidth( _ dividend: ( high: Self , low: Self . Magnitude ) )
2154
2156
-> ( quotient: Self , remainder: Self )
2155
2157
@@ -2555,11 +2557,8 @@ extension FixedWidthInteger {
2555
2557
2556
2558
% for x in binaryArithmetic[ 'Numeric'] + binaryArithmetic[ " BinaryInteger " ] [ : 1 ] :
2557
2559
% callLabel = x. firstArg + ': ' if not x. firstArg == '_' else ''
2558
- // FIXME(integers): pending optimizer work on handling the case where the
2559
- // boolean value is wrapped into a two-case enum and then immediately
2560
- // unwrapped. <rdar://problem/29004429>
2561
- // Uncomment this block and remove the corresponding one from the concrete
2562
- // types once the optimizer is ready.
2560
+ // FIXME(integers): uncomment this block and remove the corresponding one from
2561
+ // the concrete types
2563
2562
#if false
2564
2563
${ assignmentOperatorComment ( x. operator, True) }
2565
2564
@_transparent
@@ -3085,9 +3084,6 @@ public struct ${Self}
3085
3084
return Bool ( Builtin . cmp_ ${ u} lt_Int${ bits} ( lhs. _value, rhs. _value) )
3086
3085
}
3087
3086
3088
- // FIXME(integers): pending optimizer work on handling the case where the
3089
- // boolean value is wrapped into a two-case enum and then immediately
3090
- // unwrapped. <rdar://problem/29004429>
3091
3087
// See corresponding definitions in the FixedWidthInteger extension.
3092
3088
% for x in binaryArithmetic[ 'Numeric'] + binaryArithmetic[ " BinaryInteger " ] [ : 1 ] :
3093
3089
${ assignmentOperatorComment ( x. operator, True) }
@@ -3121,7 +3117,6 @@ ${assignmentOperatorComment(x.operator, True)}
3121
3117
lhs = ${ Self} ( result)
3122
3118
}
3123
3119
% end
3124
- // end of FIXME(integers)
3125
3120
3126
3121
% for x in chain( * binaryArithmetic. values ( ) ) :
3127
3122
0 commit comments