@@ -1219,6 +1219,66 @@ macro_rules! int_impl {
1219
1219
}
1220
1220
}
1221
1221
1222
+ /// Wrapping (modular) division. Computes `floor(self / other)`,
1223
+ /// wrapping around at the boundary of the type.
1224
+ ///
1225
+ /// The only case where such wrapping can occur is when one
1226
+ /// divides `MIN / -1` on a signed type (where `MIN` is the
1227
+ /// negative minimal value for the type); this is equivalent
1228
+ /// to `-MIN`, a positive value that is too large to represent
1229
+ /// in the type. In such a case, this function returns `MIN`
1230
+ /// itself..
1231
+ #[ unstable( feature = "core" , since = "1.0.0" ) ]
1232
+ #[ inline( always) ]
1233
+ pub fn wrapping_div( self , rhs: $T) -> $T {
1234
+ self . overflowing_div( rhs) . 0
1235
+ }
1236
+
1237
+ /// Wrapping (modular) remainder. Computes `self % other`,
1238
+ /// wrapping around at the boundary of the type.
1239
+ ///
1240
+ /// Such wrap-around never actually occurs mathematically;
1241
+ /// implementation artifacts make `x % y` illegal for `MIN /
1242
+ /// -1` on a signed type illegal (where `MIN` is the negative
1243
+ /// minimal value). In such a case, this function returns `0`.
1244
+ #[ unstable( feature = "core" , since = "1.0.0" ) ]
1245
+ #[ inline( always) ]
1246
+ pub fn wrapping_rem( self , rhs: $T) -> $T {
1247
+ self . overflowing_rem( rhs) . 0
1248
+ }
1249
+
1250
+ /// Wrapping (modular) negation. Computes `-self`,
1251
+ /// wrapping around at the boundary of the type.
1252
+ ///
1253
+ /// The only case where such wrapping can occur is when one
1254
+ /// negates `MIN` on a signed type (where `MIN` is the
1255
+ /// negative minimal value for the type); this is a positive
1256
+ /// value that is too large to represent in the type. In such
1257
+ /// a case, this function returns `MIN` itself.
1258
+ #[ unstable( feature = "core" , since = "1.0.0" ) ]
1259
+ #[ inline( always) ]
1260
+ pub fn wrapping_neg( self ) -> $T {
1261
+ self . overflowing_neg( ) . 0
1262
+ }
1263
+
1264
+ /// Panic-free bitwise shift-left; yields `self << mask(rhs)`,
1265
+ /// where `mask` removes any high-order bits of `rhs` that
1266
+ /// would cause the shift to exceed the bitwidth of the type.
1267
+ #[ unstable( feature = "core" , since = "1.0.0" ) ]
1268
+ #[ inline( always) ]
1269
+ pub fn wrapping_shl( self , rhs: u32 ) -> $T {
1270
+ self . overflowing_shl( rhs) . 0
1271
+ }
1272
+
1273
+ /// Panic-free bitwise shift-left; yields `self >> mask(rhs)`,
1274
+ /// where `mask` removes any high-order bits of `rhs` that
1275
+ /// would cause the shift to exceed the bitwidth of the type.
1276
+ #[ unstable( feature = "core" , since = "1.0.0" ) ]
1277
+ #[ inline( always) ]
1278
+ pub fn wrapping_shr( self , rhs: u32 ) -> $T {
1279
+ self . overflowing_shr( rhs) . 0
1280
+ }
1281
+
1222
1282
/// Raises self to the power of `exp`, using exponentiation by squaring.
1223
1283
///
1224
1284
/// # Examples
@@ -1739,6 +1799,66 @@ macro_rules! uint_impl {
1739
1799
}
1740
1800
}
1741
1801
1802
+ /// Wrapping (modular) division. Computes `floor(self / other)`,
1803
+ /// wrapping around at the boundary of the type.
1804
+ ///
1805
+ /// The only case where such wrapping can occur is when one
1806
+ /// divides `MIN / -1` on a signed type (where `MIN` is the
1807
+ /// negative minimal value for the type); this is equivalent
1808
+ /// to `-MIN`, a positive value that is too large to represent
1809
+ /// in the type. In such a case, this function returns `MIN`
1810
+ /// itself..
1811
+ #[ unstable( feature = "core" , since = "1.0.0" ) ]
1812
+ #[ inline( always) ]
1813
+ pub fn wrapping_div( self , rhs: $T) -> $T {
1814
+ self . overflowing_div( rhs) . 0
1815
+ }
1816
+
1817
+ /// Wrapping (modular) remainder. Computes `self % other`,
1818
+ /// wrapping around at the boundary of the type.
1819
+ ///
1820
+ /// Such wrap-around never actually occurs mathematically;
1821
+ /// implementation artifacts make `x % y` illegal for `MIN /
1822
+ /// -1` on a signed type illegal (where `MIN` is the negative
1823
+ /// minimal value). In such a case, this function returns `0`.
1824
+ #[ unstable( feature = "core" , since = "1.0.0" ) ]
1825
+ #[ inline( always) ]
1826
+ pub fn wrapping_rem( self , rhs: $T) -> $T {
1827
+ self . overflowing_rem( rhs) . 0
1828
+ }
1829
+
1830
+ /// Wrapping (modular) negation. Computes `-self`,
1831
+ /// wrapping around at the boundary of the type.
1832
+ ///
1833
+ /// The only case where such wrapping can occur is when one
1834
+ /// negates `MIN` on a signed type (where `MIN` is the
1835
+ /// negative minimal value for the type); this is a positive
1836
+ /// value that is too large to represent in the type. In such
1837
+ /// a case, this function returns `MIN` itself.
1838
+ #[ unstable( feature = "core" , since = "1.0.0" ) ]
1839
+ #[ inline( always) ]
1840
+ pub fn wrapping_neg( self ) -> $T {
1841
+ self . overflowing_neg( ) . 0
1842
+ }
1843
+
1844
+ /// Panic-free bitwise shift-left; yields `self << mask(rhs)`,
1845
+ /// where `mask` removes any high-order bits of `rhs` that
1846
+ /// would cause the shift to exceed the bitwidth of the type.
1847
+ #[ unstable( feature = "core" , since = "1.0.0" ) ]
1848
+ #[ inline( always) ]
1849
+ pub fn wrapping_shl( self , rhs: u32 ) -> $T {
1850
+ self . overflowing_shl( rhs) . 0
1851
+ }
1852
+
1853
+ /// Panic-free bitwise shift-left; yields `self >> mask(rhs)`,
1854
+ /// where `mask` removes any high-order bits of `rhs` that
1855
+ /// would cause the shift to exceed the bitwidth of the type.
1856
+ #[ unstable( feature = "core" , since = "1.0.0" ) ]
1857
+ #[ inline( always) ]
1858
+ pub fn wrapping_shr( self , rhs: u32 ) -> $T {
1859
+ self . overflowing_shr( rhs) . 0
1860
+ }
1861
+
1742
1862
/// Raises self to the power of `exp`, using exponentiation by squaring.
1743
1863
///
1744
1864
/// # Examples
0 commit comments