@@ -49,6 +49,8 @@ impl f32 {
4949
5050 /// Returns the largest integer less than or equal to a number.
5151 ///
52+ /// # Examples
53+ ///
5254 /// ```
5355 /// let f = 3.99_f32;
5456 /// let g = 3.0_f32;
@@ -80,6 +82,8 @@ impl f32 {
8082
8183 /// Returns the smallest integer greater than or equal to a number.
8284 ///
85+ /// # Examples
86+ ///
8387 /// ```
8488 /// let f = 3.01_f32;
8589 /// let g = 4.0_f32;
@@ -100,6 +104,8 @@ impl f32 {
100104 /// Returns the nearest integer to a number. Round half-way cases away from
101105 /// `0.0`.
102106 ///
107+ /// # Examples
108+ ///
103109 /// ```
104110 /// let f = 3.3_f32;
105111 /// let g = -3.3_f32;
@@ -115,6 +121,8 @@ impl f32 {
115121
116122 /// Returns the integer part of a number.
117123 ///
124+ /// # Examples
125+ ///
118126 /// ```
119127 /// let f = 3.3_f32;
120128 /// let g = -3.7_f32;
@@ -130,6 +138,8 @@ impl f32 {
130138
131139 /// Returns the fractional part of a number.
132140 ///
141+ /// # Examples
142+ ///
133143 /// ```
134144 /// use std::f32;
135145 ///
@@ -148,6 +158,8 @@ impl f32 {
148158 /// Computes the absolute value of `self`. Returns `NAN` if the
149159 /// number is `NAN`.
150160 ///
161+ /// # Examples
162+ ///
151163 /// ```
152164 /// use std::f32;
153165 ///
@@ -174,6 +186,8 @@ impl f32 {
174186 /// - `-1.0` if the number is negative, `-0.0` or `NEG_INFINITY`
175187 /// - `NAN` if the number is `NAN`
176188 ///
189+ /// # Examples
190+ ///
177191 /// ```
178192 /// use std::f32;
179193 ///
@@ -200,6 +214,8 @@ impl f32 {
200214 /// Using `mul_add` can be more performant than an unfused multiply-add if
201215 /// the target architecture has a dedicated `fma` CPU instruction.
202216 ///
217+ /// # Examples
218+ ///
203219 /// ```
204220 /// use std::f32;
205221 ///
@@ -225,6 +241,8 @@ impl f32 {
225241 /// In other words, the result is `self / rhs` rounded to the integer `n`
226242 /// such that `self >= n * rhs`.
227243 ///
244+ /// # Examples
245+ ///
228246 /// ```
229247 /// #![feature(euclidean_division)]
230248 /// let a: f32 = 7.0;
@@ -248,6 +266,8 @@ impl f32 {
248266 ///
249267 /// In particular, the result `n` satisfies `0 <= n < rhs.abs()`.
250268 ///
269+ /// # Examples
270+ ///
251271 /// ```
252272 /// #![feature(euclidean_division)]
253273 /// let a: f32 = 7.0;
@@ -273,6 +293,8 @@ impl f32 {
273293 ///
274294 /// Using this function is generally faster than using `powf`
275295 ///
296+ /// # Examples
297+ ///
276298 /// ```
277299 /// use std::f32;
278300 ///
@@ -289,6 +311,8 @@ impl f32 {
289311
290312 /// Raises a number to a floating point power.
291313 ///
314+ /// # Examples
315+ ///
292316 /// ```
293317 /// use std::f32;
294318 ///
@@ -311,6 +335,8 @@ impl f32 {
311335 ///
312336 /// Returns NaN if `self` is a negative number.
313337 ///
338+ /// # Examples
339+ ///
314340 /// ```
315341 /// use std::f32;
316342 ///
@@ -334,6 +360,8 @@ impl f32 {
334360
335361 /// Returns `e^(self)`, (the exponential function).
336362 ///
363+ /// # Examples
364+ ///
337365 /// ```
338366 /// use std::f32;
339367 ///
@@ -358,6 +386,8 @@ impl f32 {
358386
359387 /// Returns `2^(self)`.
360388 ///
389+ /// # Examples
390+ ///
361391 /// ```
362392 /// use std::f32;
363393 ///
@@ -376,6 +406,8 @@ impl f32 {
376406
377407 /// Returns the natural logarithm of the number.
378408 ///
409+ /// # Examples
410+ ///
379411 /// ```
380412 /// use std::f32;
381413 ///
@@ -404,6 +436,8 @@ impl f32 {
404436 /// `self.log2()` can produce more accurate results for base 2, and
405437 /// `self.log10()` can produce more accurate results for base 10.
406438 ///
439+ /// # Examples
440+ ///
407441 /// ```
408442 /// use std::f32;
409443 ///
@@ -420,6 +454,8 @@ impl f32 {
420454
421455 /// Returns the base 2 logarithm of the number.
422456 ///
457+ /// # Examples
458+ ///
423459 /// ```
424460 /// use std::f32;
425461 ///
@@ -441,6 +477,8 @@ impl f32 {
441477
442478 /// Returns the base 10 logarithm of the number.
443479 ///
480+ /// # Examples
481+ ///
444482 /// ```
445483 /// use std::f32;
446484 ///
@@ -466,6 +504,8 @@ impl f32 {
466504 /// * If `self <= other`: `0:0`
467505 /// * Else: `self - other`
468506 ///
507+ /// # Examples
508+ ///
469509 /// ```
470510 /// use std::f32;
471511 ///
@@ -493,6 +533,8 @@ impl f32 {
493533
494534 /// Takes the cubic root of a number.
495535 ///
536+ /// # Examples
537+ ///
496538 /// ```
497539 /// use std::f32;
498540 ///
@@ -512,6 +554,8 @@ impl f32 {
512554 /// Calculates the length of the hypotenuse of a right-angle triangle given
513555 /// legs of length `x` and `y`.
514556 ///
557+ /// # Examples
558+ ///
515559 /// ```
516560 /// use std::f32;
517561 ///
@@ -531,6 +575,8 @@ impl f32 {
531575
532576 /// Computes the sine of a number (in radians).
533577 ///
578+ /// # Examples
579+ ///
534580 /// ```
535581 /// use std::f32;
536582 ///
@@ -552,6 +598,8 @@ impl f32 {
552598
553599 /// Computes the cosine of a number (in radians).
554600 ///
601+ /// # Examples
602+ ///
555603 /// ```
556604 /// use std::f32;
557605 ///
@@ -573,6 +621,8 @@ impl f32 {
573621
574622 /// Computes the tangent of a number (in radians).
575623 ///
624+ /// # Examples
625+ ///
576626 /// ```
577627 /// use std::f32;
578628 ///
@@ -591,6 +641,8 @@ impl f32 {
591641 /// the range [-pi/2, pi/2] or NaN if the number is outside the range
592642 /// [-1, 1].
593643 ///
644+ /// # Examples
645+ ///
594646 /// ```
595647 /// use std::f32;
596648 ///
@@ -611,6 +663,8 @@ impl f32 {
611663 /// the range [0, pi] or NaN if the number is outside the range
612664 /// [-1, 1].
613665 ///
666+ /// # Examples
667+ ///
614668 /// ```
615669 /// use std::f32;
616670 ///
@@ -630,6 +684,8 @@ impl f32 {
630684 /// Computes the arctangent of a number. Return value is in radians in the
631685 /// range [-pi/2, pi/2];
632686 ///
687+ /// # Examples
688+ ///
633689 /// ```
634690 /// use std::f32;
635691 ///
@@ -653,6 +709,8 @@ impl f32 {
653709 /// * `y >= 0`: `arctan(y/x) + pi` -> `(pi/2, pi]`
654710 /// * `y < 0`: `arctan(y/x) - pi` -> `(-pi, -pi/2)`
655711 ///
712+ /// # Examples
713+ ///
656714 /// ```
657715 /// use std::f32;
658716 ///
@@ -682,6 +740,8 @@ impl f32 {
682740 /// Simultaneously computes the sine and cosine of the number, `x`. Returns
683741 /// `(sin(x), cos(x))`.
684742 ///
743+ /// # Examples
744+ ///
685745 /// ```
686746 /// use std::f32;
687747 ///
@@ -703,6 +763,8 @@ impl f32 {
703763 /// Returns `e^(self) - 1` in a way that is accurate even if the
704764 /// number is close to zero.
705765 ///
766+ /// # Examples
767+ ///
706768 /// ```
707769 /// use std::f32;
708770 ///
@@ -722,6 +784,8 @@ impl f32 {
722784 /// Returns `ln(1+n)` (natural logarithm) more accurately than if
723785 /// the operations were performed separately.
724786 ///
787+ /// # Examples
788+ ///
725789 /// ```
726790 /// use std::f32;
727791 ///
@@ -740,6 +804,8 @@ impl f32 {
740804
741805 /// Hyperbolic sine function.
742806 ///
807+ /// # Examples
808+ ///
743809 /// ```
744810 /// use std::f32;
745811 ///
@@ -761,6 +827,8 @@ impl f32 {
761827
762828 /// Hyperbolic cosine function.
763829 ///
830+ /// # Examples
831+ ///
764832 /// ```
765833 /// use std::f32;
766834 ///
@@ -782,6 +850,8 @@ impl f32 {
782850
783851 /// Hyperbolic tangent function.
784852 ///
853+ /// # Examples
854+ ///
785855 /// ```
786856 /// use std::f32;
787857 ///
@@ -803,6 +873,8 @@ impl f32 {
803873
804874 /// Inverse hyperbolic sine function.
805875 ///
876+ /// # Examples
877+ ///
806878 /// ```
807879 /// use std::f32;
808880 ///
@@ -825,6 +897,8 @@ impl f32 {
825897
826898 /// Inverse hyperbolic cosine function.
827899 ///
900+ /// # Examples
901+ ///
828902 /// ```
829903 /// use std::f32;
830904 ///
@@ -846,6 +920,8 @@ impl f32 {
846920
847921 /// Inverse hyperbolic tangent function.
848922 ///
923+ /// # Examples
924+ ///
849925 /// ```
850926 /// use std::f32;
851927 ///
0 commit comments