This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +100
-1
lines changed Expand file tree Collapse file tree 6 files changed +100
-1
lines changed Original file line number Diff line number Diff line change @@ -1594,6 +1594,12 @@ extern "rust-intrinsic" {
15941594 #[ rustc_nounwind]
15951595 pub fn sqrtf64 ( x : f64 ) -> f64 ;
15961596
1597+ /// Raises an `f16` to an integer power.
1598+ ///
1599+ /// The stabilized version of this intrinsic is
1600+ /// [`f16::powi`](../../std/primitive.f16.html#method.powi)
1601+ #[ rustc_nounwind]
1602+ pub fn powif16 ( a : f16 , x : i32 ) -> f16 ;
15971603 /// Raises an `f32` to an integer power.
15981604 ///
15991605 /// The stabilized version of this intrinsic is
@@ -1606,6 +1612,12 @@ extern "rust-intrinsic" {
16061612 /// [`f64::powi`](../../std/primitive.f64.html#method.powi)
16071613 #[ rustc_nounwind]
16081614 pub fn powif64 ( a : f64 , x : i32 ) -> f64 ;
1615+ /// Raises an `f128` to an integer power.
1616+ ///
1617+ /// The stabilized version of this intrinsic is
1618+ /// [`f128::powi`](../../std/primitive.f128.html#method.powi)
1619+ #[ rustc_nounwind]
1620+ pub fn powif128 ( a : f128 , x : i32 ) -> f128 ;
16091621
16101622 /// Returns the sine of an `f32`.
16111623 ///
Original file line number Diff line number Diff line change @@ -228,6 +228,16 @@ impl f128 {
228228 /// the bit pattern of NaNs are conserved over arithmetic operations, the result of
229229 /// `is_sign_positive` on a NaN might produce an unexpected result in some cases.
230230 /// See [explanation of NaN as a special value](f32) for more info.
231+ ///
232+ /// ```
233+ /// #![feature(f128)]
234+ ///
235+ /// let f = 7.0_f128;
236+ /// let g = -7.0_f128;
237+ ///
238+ /// assert!(f.is_sign_positive());
239+ /// assert!(!g.is_sign_positive());
240+ /// ```
231241 #[ inline]
232242 #[ must_use]
233243 #[ unstable( feature = "f128" , issue = "116909" ) ]
@@ -241,6 +251,16 @@ impl f128 {
241251 /// the bit pattern of NaNs are conserved over arithmetic operations, the result of
242252 /// `is_sign_negative` on a NaN might produce an unexpected result in some cases.
243253 /// See [explanation of NaN as a special value](f32) for more info.
254+ ///
255+ /// ```
256+ /// #![feature(f128)]
257+ ///
258+ /// let f = 7.0_f128;
259+ /// let g = -7.0_f128;
260+ ///
261+ /// assert!(!f.is_sign_negative());
262+ /// assert!(g.is_sign_negative());
263+ /// ```
244264 #[ inline]
245265 #[ must_use]
246266 #[ unstable( feature = "f128" , issue = "116909" ) ]
Original file line number Diff line number Diff line change @@ -224,6 +224,16 @@ impl f16 {
224224 /// the bit pattern of NaNs are conserved over arithmetic operations, the result of
225225 /// `is_sign_positive` on a NaN might produce an unexpected result in some cases.
226226 /// See [explanation of NaN as a special value](f32) for more info.
227+ ///
228+ /// ```
229+ /// #![feature(f16)]
230+ ///
231+ /// let f = 7.0_f16;
232+ /// let g = -7.0_f16;
233+ ///
234+ /// assert!(f.is_sign_positive());
235+ /// assert!(!g.is_sign_positive());
236+ /// ```
227237 #[ inline]
228238 #[ must_use]
229239 #[ unstable( feature = "f16" , issue = "116909" ) ]
@@ -237,6 +247,16 @@ impl f16 {
237247 /// the bit pattern of NaNs are conserved over arithmetic operations, the result of
238248 /// `is_sign_negative` on a NaN might produce an unexpected result in some cases.
239249 /// See [explanation of NaN as a special value](f32) for more info.
250+ ///
251+ /// ```
252+ /// #![feature(f16)]
253+ ///
254+ /// let f = 7.0_f16;
255+ /// let g = -7.0_f16;
256+ ///
257+ /// assert!(!f.is_sign_negative());
258+ /// assert!(g.is_sign_negative());
259+ /// ```
240260 #[ inline]
241261 #[ must_use]
242262 #[ unstable( feature = "f16" , issue = "116909" ) ]
Original file line number Diff line number Diff line change @@ -1111,7 +1111,6 @@ impl f64 {
11111111 /// ```
11121112 /// assert!((1f64).to_bits() != 1f64 as u64); // to_bits() is not casting!
11131113 /// assert_eq!((12.5f64).to_bits(), 0x4029000000000000);
1114- ///
11151114 /// ```
11161115 #[ must_use = "this returns the result of the operation, \
11171116 without modifying the original"]
Original file line number Diff line number Diff line change 77#[ cfg( test) ]
88mod tests;
99
10+ #[ cfg( not( test) ) ]
11+ use crate :: intrinsics;
12+
1013#[ unstable( feature = "f128" , issue = "116909" ) ]
1114pub use core:: f128:: consts;
15+
16+ #[ cfg( not( test) ) ]
17+ impl f128 {
18+ /// Raises a number to an integer power.
19+ ///
20+ /// Using this function is generally faster than using `powf`.
21+ /// It might have a different sequence of rounding operations than `powf`,
22+ /// so the results are not guaranteed to agree.
23+ ///
24+ /// # Unspecified precision
25+ ///
26+ /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
27+ /// can even differ within the same execution from one invocation to the next.
28+ #[ inline]
29+ #[ rustc_allow_incoherent_impl]
30+ #[ unstable( feature = "f128" , issue = "116909" ) ]
31+ #[ must_use = "method returns a new number and does not mutate the original value" ]
32+ pub fn powi ( self , n : i32 ) -> f128 {
33+ unsafe { intrinsics:: powif128 ( self , n) }
34+ }
35+ }
Original file line number Diff line number Diff line change 77#[ cfg( test) ]
88mod tests;
99
10+ #[ cfg( not( test) ) ]
11+ use crate :: intrinsics;
12+
1013#[ unstable( feature = "f16" , issue = "116909" ) ]
1114pub use core:: f16:: consts;
15+
16+ #[ cfg( not( test) ) ]
17+ impl f16 {
18+ /// Raises a number to an integer power.
19+ ///
20+ /// Using this function is generally faster than using `powf`.
21+ /// It might have a different sequence of rounding operations than `powf`,
22+ /// so the results are not guaranteed to agree.
23+ ///
24+ /// # Unspecified precision
25+ ///
26+ /// The precision of this function is non-deterministic. This means it varies by platform, Rust version, and
27+ /// can even differ within the same execution from one invocation to the next.
28+ #[ inline]
29+ #[ rustc_allow_incoherent_impl]
30+ #[ unstable( feature = "f16" , issue = "116909" ) ]
31+ #[ must_use = "method returns a new number and does not mutate the original value" ]
32+ pub fn powi ( self , n : i32 ) -> f16 {
33+ unsafe { intrinsics:: powif16 ( self , n) }
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments