Enum core::num::FpCategory1.0.0[−][src]

pub enum FpCategory {
    Nan,
    Infinite,
    Zero,
    Subnormal,
    Normal,
}
Expand description

浮点数的分类。

该 enum 用作 f32::classify 和 f64::classify 的返回类型。 有关更多信息,请参见他们的文档。

Examples

use std::num::FpCategory;

let num = 12.4_f32;
let inf = f32::INFINITY;
let zero = 0f32;
let sub: f32 = 1.1754942e-38;
let nan = f32::NAN;

assert_eq!(num.classify(), FpCategory::Normal);
assert_eq!(inf.classify(), FpCategory::Infinite);
assert_eq!(zero.classify(), FpCategory::Zero);
assert_eq!(nan.classify(), FpCategory::Nan);
assert_eq!(sub.classify(), FpCategory::Subnormal);
Run

Variants

Nan

“Not a Number”, 通常通过除以零获得。

Infinite

正或负无穷大。

Zero

正零或负零。

Subnormal

非规范化的浮点表示 (精度不及 Normal)。

Normal

常规浮点数。

Trait Implementations

返回值的副本。 Read more

从 source 执行复制分配。 Read more

使用给定的格式化程序格式化该值。 Read more

此方法测试 self 和 other 值是否相等,并由 == 使用。 Read more

此方法测试 !=。

Auto Trait Implementations

Blanket Implementations

获取 self 的 TypeId。 Read more

从拥有的值中一成不变地借用。 Read more

从拥有的值中借用。 Read more

执行转换。

执行转换。

发生转换错误时返回的类型。

执行转换。

发生转换错误时返回的类型。

执行转换。