Under heavy development. This site describes the intended 1.0 language. Current features and performance vary. Development status
Sn50SnThe SnAPI programming language
0.2.0 Preview 1 · Frozen documentation

FloatingClassification

Classifies the exact f16 representation with IsNaN semantics.

Sn is under heavy development. Reference extracted from this release’s bundled standard library. Public API examples are not an exhaustive compatibility test. Read the matching release guide for tested workflows and limitations. Read the status →

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) -> bool

Classifies 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) -> bool

Classifies 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) -> bool

Classifies 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) -> f16

Returns 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) -> bool

Classifies 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) -> bool

Classifies 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) -> bool

Classifies 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) -> f32

Returns 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) -> bool

Classifies 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) -> bool

Classifies 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) -> bool

Classifies 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) -> f64

Returns 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.

Documentation snapshot: October 24, 2026 About versions ↗
Searching Development · language & standard library