core::num::impl f64
本頁內容
57absacosacoshasinasinhatanatan2atanhcbrtceilclampcopysigncoscoshdiv_euclidexpexp2exp_m1floorfractfrom_bitshypotis_closeis_finiteis_infiniteis_nanis_normalis_sign_negativeis_sign_positivelerplnln_1ploglog10log2maxminmul_addnext_afternext_downnext_uppowpowireciprem_euclidroundsignumsinsinhsqrttantanhto_bitsto_degreesto_radianstotal_cmptrunc
API 參考只有英文版,由標準函式庫原始碼中的英文文件註解產生。
impl f64
Sourcepub const fn is_close(§self, other: f64, rel: f64 = 1e-9, abs: f64 = 0.0, equal_nan: bool = false) -> bool Whether
selfandotherare equal or within a relative tolerancerelof the larger magnitude, or withinabs: symmetric, Python'smath.isclose. The defaultrel(1e-9) asks for about nine equal digits; near zero onlyabshelps, so pass it when comparing with 0. Infinities are close only to themselves, NaN to nothing (unlessequal_nan).nabiassert((0.1 + 0.2).is_close(0.3)); assert(!1e-12.is_close(0.0) && 1e-12.is_close(0.0, abs: 1e-9)); assert(100.0.is_close(101.0, rel: 0.01));The gap between 1.0 and the next larger value.
The largest value.
The smallest value.
The smallest positive normal value.
Not a number: the quiet NaN with the sign bit clear on every target.
Positive infinity.
Negative infinity.
Pi.
tau = 2 pi.
Euler's number e.
pi/2.
pi/4.
1/pi.
sqrt(2).
1/sqrt(2).
ln 2.
ln 10.
log2(e).
log10(e).
The square root; NaN for a negative value (as
√self).The IEEE 754 total order:
-NaN < -inf < .. < -0 < +0 < .. < inf < NaN. Sorting by it never fails:xs.sort_by(f64::total_cmp).The IEEE 754 bit pattern.
The f64 with the IEEE 754 bit pattern
bits.truefor NaN.trueforinfor-inf.trueunless infinite or NaN.Neither zero, subnormal, infinite nor NaN.
truewhen the sign bit is clear (0.0,+inf, a positive NaN).truewhen the sign bit is set (-0.0,-inf, a negative NaN).Largest integer
<= self.Smallest integer
>= self.Nearest integer, halves away from zero.
Integer part (toward zero).
The magnitude (sign bit cleared).
Cube root.
e^self.2^self.e^self - 1, exact near zero.Natural logarithm.
ln(1 + self), exact near zero.Base-2 logarithm.
Base-10 logarithm.
Sine of
selfin radians.Cosine of
selfin radians.Tangent of
selfin radians.Arcsine in radians, in
[-pi/2, pi/2]; NaN outside[-1, 1].Arccosine in radians, in
[0, pi]; NaN outside[-1, 1].Arctangent in radians, in
[-pi/2, pi/2].Hyperbolic sine.
Hyperbolic cosine.
Hyperbolic tangent.
Inverse hyperbolic sine.
Inverse hyperbolic cosine; NaN below
1.Inverse hyperbolic tangent; NaN outside
[-1, 1].self - self.trunc().-1.0/1.0by sign; zeros and NaN are returned as they are.1.0 / self.Radians to degrees.
Degrees to radians.
ln(self) / ln(base).self^exp(powfin Rust).Angle of the point
(other, self).sqrt(self^2 + other^2)without overflow.self's magnitude withsign's sign.The smaller; a NaN operand loses to a number.
The larger; a NaN operand loses to a number.
selfto an integer power, by repeated multiplication: may round differently frompow(n as f64).self * a + bwith one rounding.selflimited tolo..=hi; NaN stays NaN. Panics iflo > hi.The quotient rounded so that
rem_euclidis never negative.The remainder in
[0, |rhs|); NaN whenrhsis 0.selfatt = 0,otheratt = 1, a straight line between and past them: exact at both ends and monotonic int(C++std::lerp).The next representable value after
selfin the direction oftoward(Cnextafter);towarditself when equal, NaN if either is.The least value greater than
self; infinity and NaN stay.The greatest value less than
self; -infinity and NaN stay.