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

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

浮点数的分类。

enum 用作 f32::classifyf64::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

NaN (不是数字) : 这个值来自于类似于 (-1.0).sqrt() 等的计算得出。

有关 NaN 的独特属性的更多信息,请参见 f32 的文档

Infinite

正无穷大或负无穷大,通常由非零数除以零产生。

Zero

正零或负零。

有关零的符号性的更多信息,请参见 f32 的文档

Subnormal

Subnormaldenormal 浮点表示 (相对于它们的大小,不如 Normal 精确)。

subnormal 数在数量级上比 Zero 大,但在数量级上小于所有 Normal 数。

Normal

常规浮点数,不是任何特殊类别。

最小的 positive normal 数是 f32::MIN_POSITIVEf64::MIN_POSITIVE,最大的 positive normal 数是 f32::MAXf64::MAX。 (与有符号整数不同,浮点数在其范围内是对称的,因此否定这些常量中的任何一个都会产生它们的负对应项。)

Trait Implementations

返回值的副本。 Read more

source 执行复制分配。 Read more

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

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

此方法测试 !=

Auto Trait Implementations

Blanket Implementations

获取 selfTypeIdRead more

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

从拥有的值中借用。 Read more

执行转换。

执行转换。

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

执行转换。

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

执行转换。