@@ -1282,4 +1282,102 @@ impl f128 {
12821282        } 
12831283        self 
12841284    } 
1285+ 
1286+     /// Computes the absolute value of `self`. 
1287+      /// 
1288+      /// This function always returns the precise result. 
1289+      /// 
1290+      /// # Examples 
1291+      /// 
1292+      /// ``` 
1293+      /// #![feature(f128)] 
1294+      /// # #[cfg(reliable_f128)] { 
1295+      /// 
1296+      /// let x = 3.5_f128; 
1297+      /// let y = -3.5_f128; 
1298+      /// 
1299+      /// assert_eq!(x.abs(), x); 
1300+      /// assert_eq!(y.abs(), -y); 
1301+      /// 
1302+      /// assert!(f128::NAN.abs().is_nan()); 
1303+      /// # } 
1304+      /// ``` 
1305+      #[ inline]  
1306+     #[ rustc_allow_incoherent_impl]  
1307+     #[ unstable( feature = "f128" ,  issue = "116909" ) ]  
1308+     #[ rustc_const_unstable( feature = "const_float_methods" ,  issue = "130843" ) ]  
1309+     #[ must_use = "method returns a new number and does not mutate the original value" ]  
1310+     pub  const  fn  abs ( self )  -> Self  { 
1311+         // FIXME(f16_f128): replace with `intrinsics::fabsf128` when available 
1312+         // We don't do this now because LLVM has lowering bugs for f128 math. 
1313+         Self :: from_bits ( self . to_bits ( )  &  !( 1  << 127 ) ) 
1314+     } 
1315+ 
1316+     /// Returns a number that represents the sign of `self`. 
1317+      /// 
1318+      /// - `1.0` if the number is positive, `+0.0` or `INFINITY` 
1319+      /// - `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY` 
1320+      /// - NaN if the number is NaN 
1321+      /// 
1322+      /// # Examples 
1323+      /// 
1324+      /// ``` 
1325+      /// #![feature(f128)] 
1326+      /// # #[cfg(reliable_f128_math)] { 
1327+      /// 
1328+      /// let f = 3.5_f128; 
1329+      /// 
1330+      /// assert_eq!(f.signum(), 1.0); 
1331+      /// assert_eq!(f128::NEG_INFINITY.signum(), -1.0); 
1332+      /// 
1333+      /// assert!(f128::NAN.signum().is_nan()); 
1334+      /// # } 
1335+      /// ``` 
1336+      #[ inline]  
1337+     #[ rustc_allow_incoherent_impl]  
1338+     #[ unstable( feature = "f128" ,  issue = "116909" ) ]  
1339+     #[ rustc_const_unstable( feature = "const_float_methods" ,  issue = "130843" ) ]  
1340+     #[ must_use = "method returns a new number and does not mutate the original value" ]  
1341+     pub  const  fn  signum ( self )  -> f128  { 
1342+         if  self . is_nan ( )  {  Self :: NAN  }  else  {  1.0_f128 . copysign ( self )  } 
1343+     } 
1344+ 
1345+     /// Returns a number composed of the magnitude of `self` and the sign of 
1346+      /// `sign`. 
1347+      /// 
1348+      /// Equal to `self` if the sign of `self` and `sign` are the same, otherwise equal to `-self`. 
1349+      /// If `self` is a NaN, then a NaN with the same payload as `self` and the sign bit of `sign` is 
1350+      /// returned. 
1351+      /// 
1352+      /// If `sign` is a NaN, then this operation will still carry over its sign into the result. Note 
1353+      /// that IEEE 754 doesn't assign any meaning to the sign bit in case of a NaN, and as Rust 
1354+      /// doesn't guarantee that the bit pattern of NaNs are conserved over arithmetic operations, the 
1355+      /// result of `copysign` with `sign` being a NaN might produce an unexpected or non-portable 
1356+      /// result. See the [specification of NaN bit patterns](primitive@f32#nan-bit-patterns) for more 
1357+      /// info. 
1358+      /// 
1359+      /// # Examples 
1360+      /// 
1361+      /// ``` 
1362+      /// #![feature(f128)] 
1363+      /// # #[cfg(reliable_f128_math)] { 
1364+      /// 
1365+      /// let f = 3.5_f128; 
1366+      /// 
1367+      /// assert_eq!(f.copysign(0.42), 3.5_f128); 
1368+      /// assert_eq!(f.copysign(-0.42), -3.5_f128); 
1369+      /// assert_eq!((-f).copysign(0.42), 3.5_f128); 
1370+      /// assert_eq!((-f).copysign(-0.42), -3.5_f128); 
1371+      /// 
1372+      /// assert!(f128::NAN.copysign(1.0).is_nan()); 
1373+      /// # } 
1374+      /// ``` 
1375+      #[ inline]  
1376+     #[ rustc_allow_incoherent_impl]  
1377+     #[ unstable( feature = "f128" ,  issue = "116909" ) ]  
1378+     #[ rustc_const_unstable( feature = "const_float_methods" ,  issue = "130843" ) ]  
1379+     #[ must_use = "method returns a new number and does not mutate the original value" ]  
1380+     pub  const  fn  copysign ( self ,  sign :  f128 )  -> f128  { 
1381+         unsafe  {  intrinsics:: copysignf128 ( self ,  sign)  } 
1382+     } 
12851383} 
0 commit comments