float
struct floatAvailable 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.
Members
constructorconstructor
public constructor ()Creates zero.
NaNconst
const float NaNA quiet not-a-number value. Test with IsNaN, since operator equality does not identify
NaNs.
Infinityconst
const float InfinityPositive infinity.
NegativeInfinityconst
const float NegativeInfinityNegative infinity.
MinValueconst
const float MinValue = -3.40282347e+38fThe smallest finite value representable by this type.
MaxValueconst
const float MaxValue = 3.40282347e+38fThe largest finite value representable by this type.
Epsilonconst
const float Epsilon = 1.1920929e-7fThe distance from 1 to the next larger representable value; this is not the smallest positive value.
MinSafeIntegerconst
const int32 MinSafeInteger = 0 - 16777216The negative boundary of the interval in which every integer is exactly representable.
MaxSafeIntegerconst
const int32 MaxSafeInteger = 16777216The positive boundary of the interval in which every integer is exactly representable.
Piconst
const float Pi = 3.14159265fThe circle constant pi.
Tauconst
const float Tau = 6.28318530fOne full revolution in radians, 2*pi.
Econst
const float E = 2.71828182fThe base of natural logarithms.
HalfPiconst
const float HalfPi = 1.57079632fHalf of pi, a right angle in radians.
QuarterPiconst
const float QuarterPi = 0.78539816fOne quarter of pi, 45 degrees in radians.
InvPiconst
const float InvPi = 0.31830988fThe reciprocal of pi.
InvSqrtPiconst
const float InvSqrtPi = 0.56418958fThe reciprocal of the square root of pi.
Sqrt2const
const float Sqrt2 = 1.41421356fThe positive square root of two.
InvSqrt2const
const float InvSqrt2 = 0.70710678fThe reciprocal of the square root of two.
Ln2const
const float Ln2 = 0.69314718fThe natural logarithm of two.
Ln10const
const float Ln10 = 2.30258509fThe natural logarithm of ten.
Log2Econst
const float Log2E = 1.44269504fThe base-2 logarithm of e.
Log10Econst
const float Log10E = 0.43429448fThe base-10 logarithm of e.
GetHashCodemethod
public fn GetHashCode() : uint32Returns a value hash, treating all NaNs alike and both signed zeros alike.
ToStringmethod
public fn ToString() : stringReturns a shortest round-trippable decimal representation, with text for infinities and NaN.
ToStringBuffermethod
public fn ToStringBuffer(StringBuilder builder) : int32Appends the same text as ToString and returns the number of UTF-8 bytes appended.
Formatmethod
public fn Format(string fmt) : stringFormats 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.
FormatBuffermethod
public fn FormatBuffer(StringBuilder builder, string fmt) : int32Appends Format(fmt) text directly to a builder and returns the number of bytes appended.
Equalsmethod
public fn Equals(float other) : boolCompares values, treating all NaNs as equal and positive and negative zero as equal.
CompareTomethod
public fn CompareTo(float other) : int32Returns -1, 0, or 1 for less, equal, or greater. NaNs compare equal to each other and greater than every non-NaN value.
IsNaNmethod
public fn IsNaN() : boolTests for any NaN bit pattern.
IsInfinitymethod
public fn IsInfinity() : boolTests for either positive or negative infinity.
IsFinitemethod
public fn IsFinite() : boolTests that the value is neither infinity nor NaN.
IsNegativeInfinitymethod
public fn IsNegativeInfinity() : boolTests specifically for negative infinity.
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.
ParseDetailedmethod
public static fn ParseDetailed(string text, FloatParseOptions options = new FloatParseOptions.General()) : float throws ParseErrorParses 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.
Reinterpretmethod
public fn Reinterpret<T>() : T where T is numericReinterprets 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.
nanosecondsgetter
public get nanoseconds() : timespanInterprets 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.
microsecondsgetter
public get microseconds() : timespanInterprets 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.
millisecondsgetter
public get milliseconds() : timespanInterprets 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.
secondsgetter
public get seconds() : timespanInterprets 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.
minutesgetter
public get minutes() : timespanInterprets 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.
hoursgetter
public get hours() : timespanInterprets 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.
degreesgetter
public get degrees() : angleInterprets this value as degrees and converts to an angle stored in float radians. Does not normalize the angle to one revolution.
radiansgetter
public get radians() : angleInterprets this value as radians and converts to an angle stored in float radians. Does not normalize the angle to one revolution.
turnsgetter
public get turns() : angleInterprets this value as turns and converts to an angle stored in float radians. Does not normalize the angle to one revolution.