渲染zh-Hant

小數

Translation status: 繁體中文 reader-locale proof. Term names and code fences follow the zh-Hant pack; supporting prose may still be English.

Primitive floating-point number type.

Aliases: float

Syntax: 小數

Category#

type

Examples#

radix/corpus/intrinseca/fractus-comparatio.fab (canonical · keyword)#

Primitive floating-point number type.

# =============================================================================
# 小數 — Primitive floating-point number type
# =============================================================================
#
# What this teaches:
#   • Primitive floating-point number type.
#   • Related keywords: 整數, ↦
#
# Common mistakes:
#   • Using `≡` for direct floating-point equality — float equality is unreliable due to precision; use `.approx()` for tolerance-based comparison.
#
# See also: 整數, ↦
# =============================================================================

# 小數 comparison and ordering intrinsics
#
# Compiler-owned 小數 methodi — absolutum, signum, minimus, maximus.
#
# GRAMMAR:
#   valor.abs() | valor.sign()
#   valor.minimum(other) | valor.maximum(other)
#
# Mirrors numerus-methodi.fab for floating-point; Wasm tier Runnable.
#
# EXPECTED OUTPUT:
#   Smoke asserts exit 0 only.

main {
    const float value ← -3.75
    const float absolutus ← value.abs()
    const float signum ← value.sign()
    const float minor ← value.minimum(2.5)
    const float maior ← value.maximum(2.5)
    print absolutus, signum, minor, maior
}