← Standard library

float

struct float

Available without an import.

IEEE 754 binary32 floating-point values, including signed zero, infinities, and NaNs. Default construction produces zero. Equals treats NaNs as equal and CompareTo sorts them last; operator equality follows floating-point comparison instead. Parsing accepts a numeric prefix; it does not validate that the entire input was consumed.

Floats.wax:46

Members

constructorconstructor

public constructor ()

Creates zero.

Floats.wax:51

NaNconst

const float NaN

A quiet not-a-number value. Test with IsNaN, since operator equality does not identify NaNs.

Floats.wax:60

Infinityconst

const float Infinity

Positive infinity.

Floats.wax:64

NegativeInfinityconst

const float NegativeInfinity

Negative infinity.

Floats.wax:68

MinValueconst

const float MinValue = -3.40282347e+38f

The smallest finite value representable by this type.

Floats.wax:72

MaxValueconst

const float MaxValue = 3.40282347e+38f

The largest finite value representable by this type.

Floats.wax:76

Epsilonconst

const float Epsilon = 1.1920929e-7f

The distance from 1 to the next larger representable value; this is not the smallest positive value.

Floats.wax:81

MinSafeIntegerconst

const int32 MinSafeInteger = 0 - 16777216

The negative boundary of the interval in which every integer is exactly representable.

Floats.wax:85

MaxSafeIntegerconst

const int32 MaxSafeInteger = 16777216

The positive boundary of the interval in which every integer is exactly representable.

Floats.wax:89

Piconst

const float Pi = 3.14159265f

The circle constant pi.

Floats.wax:95

Tauconst

const float Tau = 6.28318530f

One full revolution in radians, 2*pi.

Floats.wax:99

Econst

const float E = 2.71828182f

The base of natural logarithms.

Floats.wax:103

HalfPiconst

const float HalfPi = 1.57079632f

Half of pi, a right angle in radians.

Floats.wax:107

QuarterPiconst

const float QuarterPi = 0.78539816f

One quarter of pi, 45 degrees in radians.

Floats.wax:111

InvPiconst

const float InvPi = 0.31830988f

The reciprocal of pi.

Floats.wax:115

InvSqrtPiconst

const float InvSqrtPi = 0.56418958f

The reciprocal of the square root of pi.

Floats.wax:119

Sqrt2const

const float Sqrt2 = 1.41421356f

The positive square root of two.

Floats.wax:123

InvSqrt2const

const float InvSqrt2 = 0.70710678f

The reciprocal of the square root of two.

Floats.wax:127

Ln2const

const float Ln2 = 0.69314718f

The natural logarithm of two.

Floats.wax:131

Ln10const

const float Ln10 = 2.30258509f

The natural logarithm of ten.

Floats.wax:135

Log2Econst

const float Log2E = 1.44269504f

The base-2 logarithm of e.

Floats.wax:139

Log10Econst

const float Log10E = 0.43429448f

The base-10 logarithm of e.

Floats.wax:143

GetHashCodemethod

public fn GetHashCode() : uint32

Returns a value hash, treating all NaNs alike and both signed zeros alike.

Floats.wax:154

ToStringmethod

public fn ToString() : string

Returns a shortest round-trippable decimal representation, with text for infinities and NaN.

Floats.wax:169

ToStringBuffermethod

public fn ToStringBuffer(StringBuilder builder) : int32

Appends the same text as ToString and returns the number of UTF-8 bytes appended.

Floats.wax:176

Formatmethod

public fn Format(string fmt) : string

Formats with F/f (fixed decimal places), E/e (scientific decimal places), or G/g (significant digits). A numeric suffix selects precision, capped at 99. Empty format uses shortest text; default F precision is 2 and E precision is 6.

Floats.wax:189

FormatBuffermethod

public fn FormatBuffer(StringBuilder builder, string fmt) : int32

Appends Format(fmt) text directly to a builder and returns the number of bytes appended.

Floats.wax:196

Equalsmethod

public fn Equals(float other) : bool

Compares values, treating all NaNs as equal and positive and negative zero as equal.

Floats.wax:211

CompareTomethod

public fn CompareTo(float other) : int32

Returns -1, 0, or 1 for less, equal, or greater. NaNs compare equal to each other and greater than every non-NaN value.

Floats.wax:223

IsNaNmethod

public fn IsNaN() : bool

Tests for any NaN bit pattern.

Floats.wax:238

IsInfinitymethod

public fn IsInfinity() : bool

Tests for either positive or negative infinity.

Floats.wax:246

IsFinitemethod

public fn IsFinite() : bool

Tests that the value is neither infinity nor NaN.

Floats.wax:254

IsNegativeInfinitymethod

public fn IsNegativeInfinity() : bool

Tests specifically for negative infinity.

Floats.wax:262

Parsemethod

public static fn Parse(string text, FloatParseOptions options = new FloatParseOptions.General()) : float?

Parses a numeric prefix according to options, returning null for invalid input or an out-of-range result. Trailing text can remain unconsumed.

Floats.wax:269

ParseDetailedmethod

public static fn ParseDetailed(string text, FloatParseOptions options = new FloatParseOptions.General()) : float throws ParseError

Parses a numeric prefix according to options. Throws ParseError with a byte position for invalid input or an out-of-range result. Does not require whole-input consumption; use the low-level parser result position when checking it.

Floats.wax:279

Reinterpretmethod

public fn Reinterpret<T>() : T where T is numeric

Reinterprets bits as a numeric type of the same width rather than converting the numeric value. Incompatible widths are rejected. Floating-point NaNs are canonicalized when entering or leaving a floating-point type; NaN payload bits are not preserved.

Floats.wax:294

nanosecondsgetter

public get nanoseconds() : timespan

Interprets this value as nanoseconds and converts to a duration stored in signed 64-bit nanoseconds. Fractional nanoseconds are truncated; supply a finite value within the duration range.

Floats.wax:302

microsecondsgetter

public get microseconds() : timespan

Interprets this value as microseconds and converts to a duration stored in signed 64-bit nanoseconds. Fractional nanoseconds are truncated; supply a finite value within the duration range.

Floats.wax:308

millisecondsgetter

public get milliseconds() : timespan

Interprets this value as milliseconds and converts to a duration stored in signed 64-bit nanoseconds. Fractional nanoseconds are truncated; supply a finite value within the duration range.

Floats.wax:314

secondsgetter

public get seconds() : timespan

Interprets this value as seconds and converts to a duration stored in signed 64-bit nanoseconds. Fractional nanoseconds are truncated; supply a finite value within the duration range.

Floats.wax:320

minutesgetter

public get minutes() : timespan

Interprets this value as minutes and converts to a duration stored in signed 64-bit nanoseconds. Fractional nanoseconds are truncated; supply a finite value within the duration range.

Floats.wax:326

hoursgetter

public get hours() : timespan

Interprets this value as hours and converts to a duration stored in signed 64-bit nanoseconds. Fractional nanoseconds are truncated; supply a finite value within the duration range.

Floats.wax:332

degreesgetter

public get degrees() : angle

Interprets this value as degrees and converts to an angle stored in float radians. Does not normalize the angle to one revolution.

Floats.wax:337

radiansgetter

public get radians() : angle

Interprets this value as radians and converts to an angle stored in float radians. Does not normalize the angle to one revolution.

Floats.wax:342

turnsgetter

public get turns() : angle

Interprets this value as turns and converts to an angle stored in float radians. Does not normalize the angle to one revolution.

Floats.wax:347