FloatingClassification
Classifies the exact f16 representation with IsNaN semantics.
Module std.math
import std.math;Public declaration contracts and authored examples. A page can document several related symbols. Implementation bodies are excluded.
fn
pub const fn IsNaN(Value: f16) -> boolClassifies the exact f16 representation with IsNaN semantics. Value: Floating bits, including subnormals, signed zero and NaN payloads. Return: Classification without arithmetic, allocation or floating-status mutation.
Example
module example.floating_classification;
from std.math import IsNaN, IsFinite, IsInfinity, CopySign;
fn Main() -> i32 {
let Nan = bit_cast<f32>(0x7FC00001_u32);
let Infinity = bit_cast<f64>(0x7FF0000000000000_u64);
if !IsNaN(Nan) || IsFinite(Nan) || IsInfinity(Nan) { return 1; }
if !IsInfinity(Infinity) || IsFinite(Infinity) || IsNaN(Infinity) { return 2; }
if !IsFinite(42_f16) || IsNaN(42_f16) || IsInfinity(42_f16) { return 3; }
if bit_cast<u64>(CopySign(3_f64, -1_f64)) != 0xC008000000000000_u64 { return 4; }
if bit_cast<u16>(CopySign(0_f16, -1_f16)) != 0x8000_u16 { return 5; }
return 0;
}fn
pub const fn IsFinite(Value: f16) -> boolClassifies the exact f16 representation with IsFinite semantics. Value: Floating bits, including subnormals, signed zero and NaN payloads. Return: Classification without arithmetic, allocation or floating-status mutation.
fn
pub const fn IsInfinity(Value: f16) -> boolClassifies the exact f16 representation with IsInfinity semantics. Value: Floating bits, including subnormals, signed zero and NaN payloads. Return: Classification without arithmetic, allocation or floating-status mutation.
fn
pub const fn CopySign(Magnitude: f16, Sign: f16) -> f16Returns f16 Magnitude bits with the sign bit of Sign. Magnitude: Bits whose exponent/fraction are preserved, including NaNs. Sign: Floating value supplying only its sign bit. Return: Exact bitwise sign replacement; no arithmetic or runtime dependency.
fn
pub const fn IsNaN(Value: f32) -> boolClassifies the exact f32 representation with IsNaN semantics. Value: Floating bits, including subnormals, signed zero and NaN payloads. Return: Classification without arithmetic, allocation or floating-status mutation.
fn
pub const fn IsFinite(Value: f32) -> boolClassifies the exact f32 representation with IsFinite semantics. Value: Floating bits, including subnormals, signed zero and NaN payloads. Return: Classification without arithmetic, allocation or floating-status mutation.
fn
pub const fn IsInfinity(Value: f32) -> boolClassifies the exact f32 representation with IsInfinity semantics. Value: Floating bits, including subnormals, signed zero and NaN payloads. Return: Classification without arithmetic, allocation or floating-status mutation.
fn
pub const fn CopySign(Magnitude: f32, Sign: f32) -> f32Returns f32 Magnitude bits with the sign bit of Sign. Magnitude: Bits whose exponent/fraction are preserved, including NaNs. Sign: Floating value supplying only its sign bit. Return: Exact bitwise sign replacement; no arithmetic or runtime dependency.
fn
pub const fn IsNaN(Value: f64) -> boolClassifies the exact f64 representation with IsNaN semantics. Value: Floating bits, including subnormals, signed zero and NaN payloads. Return: Classification without arithmetic, allocation or floating-status mutation.
fn
pub const fn IsFinite(Value: f64) -> boolClassifies the exact f64 representation with IsFinite semantics. Value: Floating bits, including subnormals, signed zero and NaN payloads. Return: Classification without arithmetic, allocation or floating-status mutation.
fn
pub const fn IsInfinity(Value: f64) -> boolClassifies the exact f64 representation with IsInfinity semantics. Value: Floating bits, including subnormals, signed zero and NaN payloads. Return: Classification without arithmetic, allocation or floating-status mutation.
fn
pub const fn CopySign(Magnitude: f64, Sign: f64) -> f64Returns f64 Magnitude bits with the sign bit of Sign. Magnitude: Bits whose exponent/fraction are preserved, including NaNs. Sign: Floating value supplying only its sign bit. Return: Exact bitwise sign replacement; no arithmetic or runtime dependency.