Skip to content
Open Saka

f32

Numbers of 32-bit floating point (IEEE binary32): constants, the finite ones, conversion of a number of any shape to the nearest one, and parsing. A function runs once for each combination of the Values of its ! arguments.

Write these names after f32::, as in f32::finite.

finite

set finite = f32:{-3.4028234663852886e38..3.4028234663852886e38}

Every f32 but the infinities and nan.

from

def from[set T: numeric](value! T)! f32

The f32 nearest a number of any shape, rounding once, ties to even, and overflowing to an infinity: an int directly from its exact Value, and an f64 from its binary64 Value, so f32::from(0.1) rounds the f64 0.1. An f32 stays as it is, nan stays nan, and a negative number that rounds to zero gives 0.

pi

def pi

The binary32 Value nearest the ratio of a circle’s circumference to its diameter.

e

def e

The binary32 Value nearest the base of natural logarithms.

epsilon

def epsilon

The gap between one and the next larger f32, 2^-23; not a universal comparison tolerance.

inf

def inf

The f32 infinity.

nan

def nan

The f32 not-a-number, the greatest f32.

parse

def parse(text! str)? f32

Parses a text in f64::parse’s grammar into one f32, rounding its digits once into binary32, not through binary64, and gives an empty Bag for any other text: f32::parse("1.000000059604644775390625000001") is the f32 just above 1. Overflow gives an infinity, and negative zero becomes zero.