Skip to content

OnixLabs.Numerics.Float256

Matthew Layton edited this page Nov 15, 2026 · 3 revisions

Float256 Struct

Represents an IEEE 754 binary256 octuple-precision floating-point number with a 237-bit significand, a 19-bit biased exponent, and a full generic-math surface that integrates seamlessly with .NET's numeric type system.

Namespace OnixLabs.Numerics
Assembly OnixLabs.Numerics.dll (NuGet)
Inheritance object → ValueType → Float256
Implements IBinaryFloatingPointIeee754<Float256>, IMinMaxValue<Float256>, IValueEquatable<Float256>, IValueComparable<Float256>, IConvertible

Definition

public readonly partial struct Float256 :
    IBinaryFloatingPointIeee754<Float256>,
    IMinMaxValue<Float256>,
    IValueEquatable<Float256>,
    IValueComparable<Float256>,
    IConvertible

Remarks

Float256 implements the IEEE 754-2008 binary256 format (also called octuple precision). The 256-bit bit pattern is laid out as one sign bit, a 19-bit biased exponent (bias 262143), and a 236-bit trailing significand. For normal values an implicit leading one gives 237 significant bits of precision, which corresponds to approximately 71–73 significant decimal digits and supports finite values up to roughly ±1.61 × 10⁷⁸⁹¹³. The smallest positive subnormal is approximately 2.48 × 10⁻⁷⁸⁹⁸⁴.

NaN and infinity — Float256 models all IEEE 754 special values: positive and negative infinity, positive and negative zero, and quiet NaN. The static predicates IsNaN, IsInfinity, IsZero, IsFinite, IsNormal, and IsSubnormal test these states. Comparison operators return false whenever either operand is NaN, matching IEEE 754 ordering semantics. Equals(Float256) and GetHashCode() use collection-friendly semantics: any two NaN bit patterns are considered equal, and positive and negative zero are considered equal.

Arithmetic — all four basic operations (+, -, *, /) and the modulus operator (%) are implemented with full IEEE 754 round-to-nearest-ties-to-even semantics, operating natively in 256-bit arithmetic. FusedMultiplyAdd is a true single-rounded FMA computed in a 512-bit accumulator.

Generic-math support — because Float256 implements IBinaryFloatingPointIeee754<Float256> it participates fully in .NET's generic-math infrastructure. Any algorithm constrained to IFloatingPoint<T>, INumber<T>, or INumberBase<T> accepts Float256 without modification. Explicitly-implemented interface members (INumberBase<Float256>.IsCanonical, INumberBase<Float256>.IsComplexNumber, etc.) are accessible via the interface and are not listed in the member tables.

Transcendental functions — Float256 provides a comprehensive set of transcendental functions directly: exponential (Exp, Exp2, Exp10, ExpM1, Exp2M1, Exp10M1), logarithmic (Log, Log2, Log10, LogP1, Log2P1, Log10P1, Log(value, base)), power/root (Pow, Sqrt, Cbrt, RootN, Hypot), trigonometric (Sin, Cos, Tan, SinCos, SinPi, CosPi, TanPi, SinCosPi), inverse trigonometric (Asin, Acos, Atan, Atan2, AsinPi, AcosPi, AtanPi, Atan2Pi), and hyperbolic / inverse hyperbolic (Sinh, Cosh, Tanh, Asinh, Acosh, Atanh). All functions are evaluated using range-reduced Taylor series.

Conversions — implicit widening conversions are provided from all built-in signed and unsigned integer types (sbyte, byte, short, ushort, int, uint, long, ulong, Int128, UInt128, char), as well as from the narrower floating-point types (Half, float, double) and from decimal. An additional implicit widening conversion is provided from Float128; every binary128 value is exactly representable in binary256. Narrowing explicit conversions to integer types truncate toward zero, saturating on overflow (unchecked form) or throwing OverflowException (checked form). Conversions to and from BigDecimal and BigInteger are also provided.

Formatting and parsing — ToString supports standard numeric format strings (G/R for round-trip, plus precision-bearing specifiers such as N, F, C, P) and reads NaN, infinity, and sign symbols from the NumberFormatInfo of the supplied provider. Parse and TryParse accept both string and ReadOnlySpan<char>, with optional NumberStyles control; scientific-notation exponents (E/e) are also recognised. The round-trip digit count for binary256 is 73.

Serialisation — the floating-point exponent and significand can be written to byte spans individually in either endianness via TryWriteExponentBigEndian, TryWriteExponentLittleEndian, TryWriteSignificandBigEndian, and TryWriteSignificandLittleEndian. Note that the binary256 exponent requires a 32-bit (4-byte) serialised form — wider than the 16-bit form used by Float128 — and the significand requires 32 bytes.

Relationship to siblings — Float256 and Float128 share a symmetric public API. Float256 offers double the bit width (237-bit significand, vs 113 bits for Float128) and is used internally by Float128.ToString as a high-precision intermediate during binary-to-decimal conversion.

Examples

Construction and arithmetic

using OnixLabs.Numerics;

Float256 a = Float256.Parse("1.23456789012345678901234567890123456789012345678901234567890123456789012");
Float256 b = (Float256)3.14159265358979323846264338327950288;  // implicit from double

Float256 sum  = a + b;
Float256 prod = a * b;
Float256 quot = a / b;

Console.WriteLine(Float256.IsFinite(sum));       // True
Console.WriteLine(Float256.IsNaN(Float256.NaN)); // True
Console.WriteLine(Float256.MaxValue);            // ~1.616...E+78913
Console.WriteLine(Float256.Epsilon);             // smallest positive subnormal

Transcendental functions and formatting

using OnixLabs.Numerics;
using System.Globalization;

Float256 angle = Float256.Pi / (Float256)4;
Float256 sinVal = Float256.Sin(angle);      // ~0.70710678...
Float256 logVal = Float256.Log(Float256.E); // 1 (exactly)
Float256 sqrtTwo = Float256.Sqrt((Float256)2);

// Round-trip: 73 significant decimal digits
string rt = sqrtTwo.ToString("G", CultureInfo.InvariantCulture);
Float256 parsed = Float256.Parse(rt, CultureInfo.InvariantCulture);
Console.WriteLine(parsed == sqrtTwo); // True

// Precision-bearing format
Console.WriteLine(sinVal.ToString("N10", CultureInfo.InvariantCulture));
// 0.7071067812

// Serialise the exponent (4 bytes) and significand (32 bytes)
Span<byte> expBuf = stackalloc byte[4];
sqrtTwo.TryWriteExponentBigEndian(expBuf, out _);

Span<byte> sigBuf = stackalloc byte[32];
sqrtTwo.TryWriteSignificandBigEndian(sigBuf, out _);

Fields and Static Properties

Member Type Description
Zero Float256 Positive zero (+0).
NegativeZero Float256 Negative zero (−0).
One Float256 The value one.
NegativeOne Float256 The value negative one.
Two Float256 The value two.
Ten Float256 The value ten.
Epsilon Float256 The smallest positive subnormal (least positive value).
MaxValue Float256 The largest finite positive value.
MinValue Float256 The smallest finite negative value (most negative).
PositiveInfinity Float256 Positive infinity.
NegativeInfinity Float256 Negative infinity.
NaN Float256 The canonical quiet not-a-number value.
AllBitsSet Float256 All 256 bits set (a negative NaN).
E Float256 Euler's number, rounded to binary256 precision.
Pi Float256 The ratio π of a circle's circumference to its diameter, rounded to binary256 precision.
Tau Float256 The number of radians in one turn (2π), rounded to binary256 precision.

Zero

public static Float256 Zero { get; }

Gets the Float256 value representing positive zero. This is the default value of the struct.

NegativeZero

public static Float256 NegativeZero { get; }

Gets the Float256 value representing negative zero. Negative zero compares equal to positive zero under IEEE 754 ordering semantics.

One

public static Float256 One { get; }

Gets the Float256 value representing positive one.

NegativeOne

public static Float256 NegativeOne { get; }

Gets the Float256 value representing negative one.

Two

public static Float256 Two { get; }

Gets the Float256 value representing the integer two.

Ten

public static Float256 Ten { get; }

Gets the Float256 value representing the integer ten.

Epsilon

public static Float256 Epsilon { get; }

Gets the smallest positive finite Float256 value that is greater than zero. This is a subnormal value with only the least-significant bit of the trailing significand set; its bit pattern is UInt256.One. Approximately 2.48 × 10⁻⁷⁸⁹⁸⁴.

MaxValue

public static Float256 MaxValue { get; }

Gets the largest finite positive Float256 value. Approximately 1.61 × 10⁷⁸⁹¹³.

MinValue

public static Float256 MinValue { get; }

Gets the smallest finite negative Float256 value (the most negative finite number). Equal to −MaxValue.

PositiveInfinity

public static Float256 PositiveInfinity { get; }

Gets the Float256 value representing positive infinity.

NegativeInfinity

public static Float256 NegativeInfinity { get; }

Gets the Float256 value representing negative infinity.

NaN

public static Float256 NaN { get; }

Gets the canonical quiet not-a-number (NaN) Float256 value. All arithmetic operations that receive a NaN operand propagate NaN as the result.

AllBitsSet

public static Float256 AllBitsSet { get; }

Gets the Float256 value whose entire 256-bit pattern is ones. The bit pattern equals UInt256.MaxValue; this encodes a negative NaN.

E

public static Float256 E { get; }

Gets the natural logarithmic base (Euler's number, e ≈ 2.71828…), parsed from a 108-significant-digit decimal literal to guarantee a bit-correct binary256 result.

Pi

public static Float256 Pi { get; }

Gets the ratio of the circumference of a circle to its diameter (π ≈ 3.14159…), parsed from a 108-significant-digit decimal literal to guarantee a bit-correct binary256 result.

Tau

public static Float256 Tau { get; }

Gets the number of radians in one full turn (τ = 2π ≈ 6.28318…), parsed from a 108-significant-digit decimal literal to guarantee a bit-correct binary256 result.

Constructors

Constructor Description
Float256(UInt256) Initializes a new instance from the specified raw IEEE 754 binary256 bit pattern.

Float256(UInt256)

public Float256(UInt256 bits)

Initializes a new instance of the Float256 struct from the specified raw IEEE 754 binary256 bit pattern.

Parameter Type Description
bits UInt256 The raw 256-bit IEEE 754 binary256 bit pattern.

Properties

Property Type Description
Bits UInt256 Gets the raw IEEE 754 binary256 bit pattern of the current value.

Bits

public UInt256 Bits { get; }

Gets the raw 256-bit IEEE 754 binary256 representation of the current Float256 value. This property provides direct access to the bit pattern for low-level manipulation, serialisation, or construction of derived values.

Methods

Static Methods

Arithmetic

Method Returns Description
Abs(Float256) Float256 Returns the absolute value, preserving NaN payloads.
Negate(Float256) Float256 Returns the unary negation of the value.
Sign(Float256) int Returns −1, 0, or 1 indicating the sign.
Add(Float256, Float256) Float256 Computes the IEEE 754 round-to-nearest sum.
Subtract(Float256, Float256) Float256 Computes the IEEE 754 round-to-nearest difference.
Multiply(Float256, Float256) Float256 Computes the IEEE 754 round-to-nearest product.
Divide(Float256, Float256) Float256 Computes the IEEE 754 round-to-nearest quotient.
Modulus(Float256, Float256) Float256 Computes the truncating remainder.
FusedMultiplyAdd(Float256, Float256, Float256) Float256 Computes (left × right) + addend with a single final rounding.
Ieee754Remainder(Float256, Float256) Float256 Computes the IEEE 754 remainder using round-to-nearest-even on the quotient.
CopySign(Float256, Float256) Float256 Returns a value with the magnitude of magnitude and the sign of sign.

Rounding and truncation

Method Returns Description
Ceiling(Float256) Float256 Rounds toward positive infinity.
Floor(Float256) Float256 Rounds toward negative infinity.
Truncate(Float256) Float256 Rounds toward zero.
Round(Float256) Float256 Rounds to the nearest integer; ties to even.
Round(Float256, int) Float256 Rounds to a specified number of digits; ties to even.
Round(Float256, MidpointRounding) Float256 Rounds to the nearest integer using the specified midpoint strategy.
Round(Float256, int, MidpointRounding) Float256 Rounds to a specified number of digits using the specified midpoint strategy.

Comparison and clamping

Method Returns Description
Compare(Float256, Float256) int Imposes a total order; NaN sorts before all numeric values.
Min(Float256, Float256) Float256 Returns the smaller of two values; propagates NaN.
Max(Float256, Float256) Float256 Returns the larger of two values; propagates NaN.
MinNumber(Float256, Float256) Float256 Returns the smaller value; treats NaN as missing.
MaxNumber(Float256, Float256) Float256 Returns the larger value; treats NaN as missing.
MinMagnitude(Float256, Float256) Float256 Returns the value with the smaller absolute magnitude; propagates NaN.
MaxMagnitude(Float256, Float256) Float256 Returns the value with the larger absolute magnitude; propagates NaN.
MinMagnitudeNumber(Float256, Float256) Float256 Returns the value with the smaller absolute magnitude; treats NaN as missing.
MaxMagnitudeNumber(Float256, Float256) Float256 Returns the value with the larger absolute magnitude; treats NaN as missing.

Scaling and bit-manipulation

Method Returns Description
ILogB(Float256) int Returns the unbiased binary exponent; int.MaxValue for NaN/infinity; int.MinValue for zero.
ScaleB(Float256, int) Float256 Returns value × 2^n, saturating to infinity on overflow and to zero on underflow.
BitIncrement(Float256) Float256 Returns the next representable value above the argument.
BitDecrement(Float256) Float256 Returns the next representable value below the argument.
ReciprocalEstimate(Float256) Float256 Returns the correctly-rounded quotient 1 / value.
ReciprocalSqrtEstimate(Float256) Float256 Returns an approximation of 1 / √value, faithful to within 1 ULP.

Predicates

Method Returns Description
IsNaN(Float256) bool Returns true when the value is NaN.
IsInfinity(Float256) bool Returns true when the value is positive or negative infinity.
IsPositiveInfinity(Float256) bool Returns true when the value is positive infinity.
IsNegativeInfinity(Float256) bool Returns true when the value is negative infinity.
IsFinite(Float256) bool Returns true when the value is finite (not NaN, not infinity).
IsNormal(Float256) bool Returns true when the value is a normal (non-zero, non-subnormal, non-infinite, non-NaN) value.
IsSubnormal(Float256) bool Returns true when the value is a non-zero subnormal.
IsZero(Float256) bool Returns true when the value is positive or negative zero.
IsNegative(Float256) bool Returns true when the sign bit is set (including negative zero and negative NaN).
IsPositive(Float256) bool Returns true when the sign bit is clear (including positive zero and canonical NaN).
IsInteger(Float256) bool Returns true when the value is a finite integer.
IsEvenInteger(Float256) bool Returns true when the value is an even finite integer.
IsOddInteger(Float256) bool Returns true when the value is an odd finite integer.
IsPow2(Float256) bool Returns true when the value is a positive power of two.

Exponential functions

Method Returns Description
Exp(Float256) Float256 Computes e^value.
Exp2(Float256) Float256 Computes 2^value.
Exp10(Float256) Float256 Computes 10^value.
ExpM1(Float256) Float256 Computes e^value − 1, accurate near zero.
Exp2M1(Float256) Float256 Computes 2^value − 1, accurate near zero.
Exp10M1(Float256) Float256 Computes 10^value − 1, accurate near zero.

Logarithmic functions

Method Returns Description
Log(Float256) Float256 Computes the natural logarithm.
Log2(Float256) Float256 Computes the base-2 logarithm.
Log10(Float256) Float256 Computes the base-10 logarithm.
Log(Float256, Float256) Float256 Computes the logarithm in a specified base.
LogP1(Float256) Float256 Computes ln(1 + value), accurate near zero.
Log2P1(Float256) Float256 Computes log2(1 + value), accurate near zero.
Log10P1(Float256) Float256 Computes log10(1 + value), accurate near zero.

Power and root functions

Method Returns Description
Pow(Float256, Float256) Float256 Computes x^y following IEEE 754-2019 special-case rules.
Sqrt(Float256) Float256 Computes the square root; faithful to within 1 ULP.
Cbrt(Float256) Float256 Computes the cube root; preserves the sign of negative inputs.
RootN(Float256, int) Float256 Computes the _n_th root.
Hypot(Float256, Float256) Float256 Computes √(x² + y²), avoiding intermediate overflow.

Trigonometric functions

Method Returns Description
Sin(Float256) Float256 Computes the sine of an angle in radians.
Cos(Float256) Float256 Computes the cosine of an angle in radians.
Tan(Float256) Float256 Computes the tangent of an angle in radians.
SinCos(Float256) (Float256 Sin, Float256 Cos) Computes sine and cosine simultaneously.
SinPi(Float256) Float256 Computes sin(π · value).
CosPi(Float256) Float256 Computes cos(π · value).
TanPi(Float256) Float256 Computes tan(π · value).
SinCosPi(Float256) (Float256 SinPi, Float256 CosPi) Computes sin(π · value) and cos(π · value) simultaneously.

Inverse trigonometric functions

Method Returns Description
Asin(Float256) Float256 Computes the arcsine; input in [−1, 1]; result in radians.
Acos(Float256) Float256 Computes the arccosine; input in [−1, 1]; result in radians.
Atan(Float256) Float256 Computes the arctangent; result in radians.
Atan2(Float256, Float256) Float256 Computes atan(y/x) accounting for quadrant; result in radians.
AsinPi(Float256) Float256 Computes Asin(value) / π.
AcosPi(Float256) Float256 Computes Acos(value) / π.
AtanPi(Float256) Float256 Computes Atan(value) / π.
Atan2Pi(Float256, Float256) Float256 Computes Atan2(y, x) / π.

Hyperbolic functions

Method Returns Description
Sinh(Float256) Float256 Computes the hyperbolic sine.
Cosh(Float256) Float256 Computes the hyperbolic cosine.
Tanh(Float256) Float256 Computes the hyperbolic tangent.
Asinh(Float256) Float256 Computes the inverse hyperbolic sine.
Acosh(Float256) Float256 Computes the inverse hyperbolic cosine; domain [1, +∞).
Atanh(Float256) Float256 Computes the inverse hyperbolic tangent; domain [−1, 1].

Parsing

Method Returns Description
Parse(string, IFormatProvider?) Float256 Parses a string.
Parse(string, NumberStyles, IFormatProvider?) Float256 Parses a string with explicit number styles.
Parse(ReadOnlySpan&lt;char&gt;, IFormatProvider?) Float256 Parses a character span.
Parse(ReadOnlySpan&lt;char&gt;, NumberStyles, IFormatProvider?) Float256 Parses a character span with explicit number styles.
TryParse(string?, out Float256) bool Attempts to parse a string; returns false on failure.
TryParse(string?, IFormatProvider?, out Float256) bool Attempts to parse a string with a format provider.
TryParse(string?, NumberStyles, IFormatProvider?, out Float256) bool Attempts to parse a string with number styles and a format provider.
TryParse(ReadOnlySpan&lt;char&gt;, out Float256) bool Attempts to parse a character span; returns false on failure.
TryParse(ReadOnlySpan&lt;char&gt;, IFormatProvider?, out Float256) bool Attempts to parse a character span with a format provider.
TryParse(ReadOnlySpan&lt;char&gt;, NumberStyles, IFormatProvider?, out Float256) bool Attempts to parse a character span with number styles and a format provider.

Equality

Method Returns Description
Equals(Float256, Float256) bool Determines whether two Float256 values are equal under collection-equality semantics.

Abs(Float256)

public static Float256 Abs(Float256 value)

Returns the absolute value of value by clearing the sign bit. NaN payloads are preserved: any NaN input produces a NaN result. Negative zero becomes positive zero; negative infinity becomes positive infinity.

Parameter Type Description
value Float256 The value whose absolute value is to be computed.

Returns — The absolute value of value.

Negate(Float256)

public static Float256 Negate(Float256 value)

Returns the unary negation of value. Equivalent to applying the − unary operator.

Parameter Type Description
value Float256 The value to negate.

Returns — The negation of value.

Sign(Float256)

public static int Sign(Float256 value)

Returns an integer indicating the sign of the specified value.

Parameter Type Description
value Float256 The value whose sign is to be returned.

Returns — −1 if value is negative; 0 if value is zero; 1 if value is positive.

Exceptions

Exception Condition
ArithmeticException value is NaN.

Add(Float256, Float256)

public static Float256 Add(Float256 left, Float256 right)

Computes the sum of two Float256 values, rounded to nearest, ties-to-even per IEEE 754.

Parameter Type Description
left Float256 The left addend.
right Float256 The right addend.

Returns — The correctly-rounded sum.

Subtract(Float256, Float256)

public static Float256 Subtract(Float256 left, Float256 right)

Computes the difference of two Float256 values, rounded to nearest, ties-to-even per IEEE 754.

Parameter Type Description
left Float256 The minuend.
right Float256 The subtrahend.

Returns — The correctly-rounded difference.

Multiply(Float256, Float256)

public static Float256 Multiply(Float256 left, Float256 right)

Computes the product of two Float256 values, rounded to nearest, ties-to-even per IEEE 754. The full 512-bit product of the two 237-bit significands is computed before rounding.

Parameter Type Description
left Float256 The left multiplicand.
right Float256 The right multiplicand.

Returns — The correctly-rounded product.

Divide(Float256, Float256)

public static Float256 Divide(Float256 left, Float256 right)

Computes the quotient of two Float256 values, rounded to nearest, ties-to-even per IEEE 754.

Parameter Type Description
left Float256 The dividend.
right Float256 The divisor.

Returns — The correctly-rounded quotient; NaN if both are zero or if left is infinity and right is infinity; PositiveInfinity or NegativeInfinity if right is zero.

Modulus(Float256, Float256)

public static Float256 Modulus(Float256 left, Float256 right)

Computes the truncating remainder of dividing left by right (C# % semantics, not the IEEE 754 remainder). The result has the same sign as the dividend.

Parameter Type Description
left Float256 The dividend.
right Float256 The divisor.

Returns — The truncating remainder.

FusedMultiplyAdd(Float256, Float256, Float256)

public static Float256 FusedMultiplyAdd(Float256 left, Float256 right, Float256 addend)

Computes (left × right) + addend with a single final rounding, eliminating intermediate rounding error. The product is computed exactly in a 512-bit intermediate and accumulated in a wider buffer before the single round-to-nearest-ties-to-even step.

Parameter Type Description
left Float256 The first multiplicand.
right Float256 The second multiplicand.
addend Float256 The value to add to the product.

Returns — (left × right) + addend with a single final rounding; NaN when any operand is NaN or for the indeterminate form 0 × ∞.

Ieee754Remainder(Float256, Float256)

public static Float256 Ieee754Remainder(Float256 left, Float256 right)

Computes the IEEE 754 remainder of left divided by right. The remainder is defined as left − n × right, where n is left / right rounded to the nearest integer with ties to even. Every arithmetic step is exact.

Parameter Type Description
left Float256 The dividend.
right Float256 The divisor.

Returns — The IEEE 754 remainder; NaN for invalid combinations (infinity dividend, zero divisor, or any NaN operand).

CopySign(Float256, Float256)

public static Float256 CopySign(Float256 magnitude, Float256 sign)

Returns a Float256 value with the magnitude of magnitude and the sign bit of sign.

Parameter Type Description
magnitude Float256 The value whose magnitude is used.
sign Float256 The value whose sign bit is used.

Returns — A value combining the magnitude of magnitude with the sign of sign.

Ceiling(Float256)

public static Float256 Ceiling(Float256 value)

Computes the smallest integral Float256 value that is greater than or equal to value (rounds toward positive infinity). NaN, ±infinity, and ±zero are returned unchanged.

Returns — The ceiling of value.

Floor(Float256)

public static Float256 Floor(Float256 value)

Computes the largest integral Float256 value that is less than or equal to value (rounds toward negative infinity). NaN, ±infinity, and ±zero are returned unchanged.

Returns — The floor of value.

Truncate(Float256)

public static Float256 Truncate(Float256 value)

Computes the integral component of value by rounding toward zero. Fractional bits in the significand are masked out. NaN, ±infinity, and ±zero are returned unchanged.

Returns — The integral component of value.

Round(Float256)

public static Float256 Round(Float256 value)

Rounds value to the nearest integer using round-half-to-even (banker's rounding) for ties. NaN, ±infinity, and ±zero are returned unchanged.

Returns — The nearest integer value.

Round(Float256, int)

public static Float256 Round(Float256 value, int digits)

Rounds value to digits fractional digits using round-half-to-even for ties. A negative digits argument rounds to a corresponding power of ten in the integer part.

Parameter Type Description
value Float256 The value to round.
digits int The number of fractional digits.

Returns — The rounded value.

Round(Float256, MidpointRounding)

public static Float256 Round(Float256 value, MidpointRounding mode)

Rounds value to the nearest integer using the specified midpoint-rounding strategy.

Parameter Type Description
value Float256 The value to round.
mode MidpointRounding The rounding strategy for values exactly halfway between two integers.

Returns — The rounded value.

Exceptions

Exception Condition
ArgumentOutOfRangeException mode is not a defined MidpointRounding value.

Round(Float256, int, MidpointRounding)

public static Float256 Round(Float256 value, int digits, MidpointRounding mode)

Rounds value to digits fractional digits using the specified midpoint-rounding strategy.

Parameter Type Description
value Float256 The value to round.
digits int The number of fractional digits.
mode MidpointRounding The rounding strategy.

Returns — The rounded value.

Exceptions

Exception Condition
ArgumentOutOfRangeException mode is not a defined MidpointRounding value.

Compare(Float256, Float256)

public static int Compare(Float256 left, Float256 right)

Compares two Float256 values and returns a signed ordering indicator. Imposes a total order: any NaN sorts before all numeric values; negative infinity is the smallest numeric value; positive zero and negative zero compare equal.

Parameter Type Description
left Float256 The left value.
right Float256 The right value.

Returns — A negative integer if left precedes right; zero if they are equal; a positive integer if left follows right.

Min(Float256, Float256)

public static Float256 Min(Float256 x, Float256 y)

Returns the smaller of two values. Returns NaN if either operand is NaN. When values are equal, the negative value (including negative zero) is preferred.

Returns — The lesser of x and y; NaN if either is NaN.

Max(Float256, Float256)

public static Float256 Max(Float256 x, Float256 y)

Returns the larger of two values. Returns NaN if either operand is NaN. When values are equal, the positive value is preferred.

Returns — The greater of x and y; NaN if either is NaN.

MinNumber(Float256, Float256)

public static Float256 MinNumber(Float256 x, Float256 y)

Returns the smaller of two values, treating NaN as missing. If exactly one operand is NaN, returns the non-NaN operand; if both are NaN, returns NaN.

MaxNumber(Float256, Float256)

public static Float256 MaxNumber(Float256 x, Float256 y)

Returns the larger of two values, treating NaN as missing.

MinMagnitude(Float256, Float256)

public static Float256 MinMagnitude(Float256 x, Float256 y)

Returns the value with the smaller absolute magnitude; propagates NaN. When magnitudes are equal, the negative value is preferred.

MaxMagnitude(Float256, Float256)

public static Float256 MaxMagnitude(Float256 x, Float256 y)

Returns the value with the larger absolute magnitude; propagates NaN. When magnitudes are equal, the positive value is preferred.

MinMagnitudeNumber(Float256, Float256)

public static Float256 MinMagnitudeNumber(Float256 x, Float256 y)

Returns the value with the smaller absolute magnitude; treats NaN as missing.

MaxMagnitudeNumber(Float256, Float256)

public static Float256 MaxMagnitudeNumber(Float256 x, Float256 y)

Returns the value with the larger absolute magnitude; treats NaN as missing.

ILogB(Float256)

public static int ILogB(Float256 value)

Returns the integral base-2 logarithm (unbiased binary exponent) of value.

Parameter Type Description
value Float256 The value to inspect.

Returns — The unbiased exponent; int.MaxValue for NaN or infinity; int.MinValue for zero.

ScaleB(Float256, int)

public static Float256 ScaleB(Float256 value, int n)

Returns value × 2^n. NaN, infinity, and zero are returned unchanged. Overflows saturate to the appropriately-signed infinity; underflows taper to subnormal or signed zero.

Parameter Type Description
value Float256 The value to scale.
n int The integer power of two.

Returns — value × 2^n.

BitIncrement(Float256)

public static Float256 BitIncrement(Float256 value)

Returns the smallest Float256 value that is greater than value. NaN remains NaN; positive infinity remains positive infinity; negative infinity becomes MinValue; either zero becomes Epsilon.

BitDecrement(Float256)

public static Float256 BitDecrement(Float256 value)

Returns the largest Float256 value that is less than value. NaN remains NaN; negative infinity remains negative infinity; positive infinity becomes MaxValue; either zero becomes the largest negative subnormal.

ReciprocalEstimate

public static Float256 ReciprocalEstimate(Float256 value)

Returns the correctly-rounded quotient 1 / value.

ReciprocalSqrtEstimate

public static Float256 ReciprocalSqrtEstimate(Float256 value)

Returns an approximation of 1 / √value, faithful to within 1 ULP (inheriting the accuracy of Sqrt).

IsNaN(Float256)

public static bool IsNaN(Float256 value)

Returns true when value is a not-a-number (NaN) value.

IsInfinity

public static bool IsInfinity(Float256 value)

Returns true when value is positive or negative infinity.

IsPositiveInfinity

public static bool IsPositiveInfinity(Float256 value)

Returns true when value is positive infinity.

IsNegativeInfinity

public static bool IsNegativeInfinity(Float256 value)

Returns true when value is negative infinity.

IsFinite

public static bool IsFinite(Float256 value)

Returns true when value is finite (not NaN and not infinity).

IsNormal

public static bool IsNormal(Float256 value)

Returns true when value is a normal value — finite, non-zero, and not subnormal.

IsSubnormal

public static bool IsSubnormal(Float256 value)

Returns true when value is a non-zero subnormal value (biased exponent field equals zero and trailing significand is non-zero).

IsZero

public static bool IsZero(Float256 value)

Returns true when value is positive zero or negative zero.

IsNegative

public static bool IsNegative(Float256 value)

Returns true when the sign bit of value is set. This includes negative zero and negative NaN bit patterns.

IsPositive

public static bool IsPositive(Float256 value)

Returns true when the sign bit of value is clear. This includes positive zero and the canonical NaN bit pattern.

IsInteger

public static bool IsInteger(Float256 value)

Returns true when value is a finite number with no fractional component (an exact integer). Returns false for NaN, infinity, and values whose magnitude is less than 1 with non-zero fractional bits.

IsEvenInteger

public static bool IsEvenInteger(Float256 value)

Returns true when value is a finite even integer.

IsOddInteger

public static bool IsOddInteger(Float256 value)

Returns true when value is a finite odd integer.

IsPow2

public static bool IsPow2(Float256 value)

Returns true when value is a positive integer that is an exact power of two.

Exp(Float256)

public static Float256 Exp(Float256 value)

Computes e^value. Returns NaN for NaN; PositiveInfinity for positive infinity or overflow; Zero for negative infinity or underflow.

Exp2(Float256)

public static Float256 Exp2(Float256 value)

Computes 2^value. For integer arguments that fit in the binary256 exponent range, the result is exact via ScaleB. Returns NaN for NaN; PositiveInfinity on overflow; Zero on underflow.

Exp10(Float256)

public static Float256 Exp10(Float256 value)

Computes 10^value via Exp(value × ln 10). Returns NaN for NaN; PositiveInfinity on overflow; Zero on underflow.

ExpM1(Float256)

public static Float256 ExpM1(Float256 value)

Computes e^value − 1, using the direct Taylor series for small value to avoid catastrophic cancellation near zero. Returns NegativeOne for negative infinity; preserves the sign of zero.

Exp2M1(Float256)

public static Float256 Exp2M1(Float256 value)

Computes 2^value − 1, accurate near zero. Returns NegativeOne for negative infinity.

Exp10M1(Float256)

public static Float256 Exp10M1(Float256 value)

Computes 10^value − 1, accurate near zero. Returns NegativeOne for negative infinity.

Log(Float256)

public static Float256 Log(Float256 value)

Computes the natural logarithm of value. Returns NaN for negative inputs and NaN; NegativeInfinity for zero; PositiveInfinity for positive infinity.

Log2(Float256)

public static Float256 Log2(Float256 value)

Computes the base-2 logarithm of value. For exact powers of two, returns the unbiased exponent as a Float256 integer. Returns NaN for negative inputs and NaN; NegativeInfinity for zero.

Log10(Float256)

public static Float256 Log10(Float256 value)

Computes the base-10 logarithm of value. Returns NaN for negative inputs and NaN; NegativeInfinity for zero.

Log(Float256, Float256)

public static Float256 Log(Float256 value, Float256 newBase)

Computes the logarithm of value in base newBase. Dispatches to Log2 when newBase is two, and to Log10 when newBase is ten; otherwise computes Log(value) / Log(newBase). Returns NaN when newBase is one.

Parameter Type Description
value Float256 The value whose logarithm is to be computed.
newBase Float256 The logarithm base.

Returns — log_newBase_(value).

LogP1(Float256)

public static Float256 LogP1(Float256 value)

Computes ln(1 + value), using the atanh Taylor series directly for small |value| to retain precision near zero. Returns NaN for inputs less than −1; NegativeInfinity when value == −1; PositiveInfinity for positive infinity.

Log2P1(Float256)

public static Float256 Log2P1(Float256 value)

Computes log2(1 + value), accurate near zero.

Log10P1(Float256)

public static Float256 Log10P1(Float256 value)

Computes log10(1 + value), accurate near zero.

Pow(Float256, Float256)

public static Float256 Pow(Float256 x, Float256 y)

Computes x^y following IEEE 754-2019 special-case rules. For positive integer exponents up to 64, exact integer exponentiation by squaring is used; for all other cases the computation falls back to Exp(y × Log(x)).

Parameter Type Description
x Float256 The base.
y Float256 The exponent.

Returns — x^y.

Sqrt(Float256)

public static Float256 Sqrt(Float256 value)

Computes the square root of value, faithful to within 1 ULP using Newton-Raphson iteration seeded from an exponent-derived estimate that is valid across the full binary256 range. Returns NaN for negative inputs or NaN; preserves the sign of zero.

Parameter Type Description
value Float256 The radicand.

Returns — √value.

Cbrt(Float256)

public static Float256 Cbrt(Float256 value)

Computes the cube root of value using Newton-Raphson iteration. Preserves the sign of negative inputs and the sign of zero; ±infinity for ±infinity.

RootN(Float256, int)

public static Float256 RootN(Float256 value, int n)

Computes the _n_th root of value. Dispatches to Sqrt for n == 2, Cbrt for n == 3, and 1 / value for n == -1; otherwise computes Exp(Log(|value|) / n). Returns NaN for an even root of a negative value; NaN for n == 0.

Parameter Type Description
value Float256 The radicand.
n int The root index.

Returns — The _n_th root of value.

Hypot(Float256, Float256)

public static Float256 Hypot(Float256 x, Float256 y)

Computes √(x² + y²) (Euclidean length), avoiding intermediate overflow by dividing through by max(|x|, |y|) before squaring.

Parameter Type Description
x Float256 The first value.
y Float256 The second value.

Returns — √(x² + y²); PositiveInfinity if either argument is infinite.

Sin(Float256)

public static Float256 Sin(Float256 value)

Computes the sine of value (angle in radians). Returns NaN for NaN or infinity; preserves the sign of zero.

Cos(Float256)

public static Float256 Cos(Float256 value)

Computes the cosine of value (angle in radians). Returns NaN for NaN or infinity; returns One for zero.

Tan(Float256)

public static Float256 Tan(Float256 value)

Computes the tangent of value (angle in radians). Returns NaN for NaN or infinity; preserves the sign of zero.

SinCos(Float256)

public static (Float256 Sin, Float256 Cos) SinCos(Float256 value)

Computes the sine and cosine of value simultaneously, sharing the underlying range-reduction and series evaluations.

Parameter Type Description
value Float256 The angle, in radians.

Returns — A tuple (Sin, Cos).

SinPi(Float256)

public static Float256 SinPi(Float256 value)

Computes sin(π · value). Returns exact zero for integer arguments.

CosPi(Float256)

public static Float256 CosPi(Float256 value)

Computes cos(π · value). Returns One for zero.

TanPi(Float256)

public static Float256 TanPi(Float256 value)

Computes tan(π · value). Returns exact zero for integer arguments.

SinCosPi(Float256)

public static (Float256 SinPi, Float256 CosPi) SinCosPi(Float256 value)

Computes sin(π · value) and cos(π · value) simultaneously.

Returns — A tuple (SinPi, CosPi).

Asin(Float256)

public static Float256 Asin(Float256 value)

Computes the arcsine of value, returning the angle in radians. Domain: [−1, 1]. Returns NaN for NaN or values outside the domain; preserves the sign of zero.

Acos(Float256)

public static Float256 Acos(Float256 value)

Computes the arccosine of value, returning the angle in radians. Domain: [−1, 1]. Returns NaN for NaN or values outside the domain.

Atan(Float256)

public static Float256 Atan(Float256 value)

Computes the arctangent of value, returning the angle in radians in the range (−π/2, π/2). Preserves the sign of zero; returns ±π/2 for ±infinity.

Atan2(Float256, Float256)

public static Float256 Atan2(Float256 y, Float256 x)

Computes atan(y/x), resolving the quadrant of the result from the signs of both arguments. Returns the angle in radians in the range (−π, π].

Parameter Type Description
y Float256 The numerator (y-coordinate).
x Float256 The denominator (x-coordinate).

Returns — The angle in radians whose tangent is y/x.

AsinPi(Float256)

public static Float256 AsinPi(Float256 value)

Computes Asin(value) / π.

AcosPi(Float256)

public static Float256 AcosPi(Float256 value)

Computes Acos(value) / π.

AtanPi(Float256)

public static Float256 AtanPi(Float256 value)

Computes Atan(value) / π; returns ±½ for ±infinity.

Atan2Pi(Float256, Float256)

public static Float256 Atan2Pi(Float256 y, Float256 x)

Computes Atan2(y, x) / π, resolving all four quadrants.

Sinh(Float256)

public static Float256 Sinh(Float256 value)

Computes the hyperbolic sine of value. Preserves the sign of zero; returns ±infinity for ±infinity or on overflow.

Cosh(Float256)

public static Float256 Cosh(Float256 value)

Computes the hyperbolic cosine of value. Returns One for zero; PositiveInfinity for ±infinity or on overflow.

Tanh(Float256)

public static Float256 Tanh(Float256 value)

Computes the hyperbolic tangent of value. Saturates to ±1 for large magnitudes and for ±infinity; preserves the sign of zero.

Asinh(Float256)

public static Float256 Asinh(Float256 value)

Computes the inverse hyperbolic sine of value. Preserves the sign of zero; returns ±infinity for ±infinity.

Acosh(Float256)

public static Float256 Acosh(Float256 value)

Computes the inverse hyperbolic cosine of value. Domain: [1, +∞). Returns NaN for inputs less than one; Zero for one; PositiveInfinity for positive infinity.

Atanh(Float256)

public static Float256 Atanh(Float256 value)

Computes the inverse hyperbolic tangent of value. Domain: [−1, 1]. Preserves the sign of zero; returns ±infinity at ±1; NaN for inputs outside the domain.

Parse(string, IFormatProvider?)

public static Float256 Parse(string value, IFormatProvider? provider = null)

Parses a string representation of a Float256 value. Recognises the culture-specific NaN, positive-infinity, and negative-infinity symbols, decimal digits, an optional decimal point, and an optional E/e exponent marker.

Parameter Type Description
value string The string to parse.
provider IFormatProvider? An optional culture-specific format provider.

Returns — The parsed Float256 value.

Exceptions

Exception Condition
FormatException value is not in a valid format.

Parse(string, NumberStyles, IFormatProvider?)

public static Float256 Parse(string value, NumberStyles style, IFormatProvider? provider = null)

Parses a string representation using the specified NumberStyles.

Parameter Type Description
value string The string to parse.
style NumberStyles A bitwise combination of number-style flags governing which components are allowed.
provider IFormatProvider? An optional culture-specific format provider.

Returns — The parsed Float256 value.

Exceptions

Exception Condition
FormatException value is not in a valid format.

Parse(ReadOnlySpan<char>, IFormatProvider?)

public static Float256 Parse(ReadOnlySpan<char> value, IFormatProvider? provider = null)

Parses a character span. Avoids string allocation.

Parameter Type Description
value ReadOnlySpan<char> The character span to parse.
provider IFormatProvider? An optional culture-specific format provider.

Returns — The parsed Float256 value.

Exceptions

Exception Condition
FormatException The span is not in a valid format.

Parse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?)

public static Float256 Parse(ReadOnlySpan<char> value, NumberStyles style, IFormatProvider? provider = null)

Parses a character span using the specified NumberStyles.

Parameter Type Description
value ReadOnlySpan<char> The character span to parse.
style NumberStyles A bitwise combination of number-style flags.
provider IFormatProvider? An optional culture-specific format provider.

Returns — The parsed Float256 value.

Exceptions

Exception Condition
FormatException The span is not in a valid format.

TryParse(string?, out Float256)

public static bool TryParse(string? value, out Float256 result)

Attempts to parse a string into a Float256 value. Returns false without throwing if parsing fails.

Parameter Type Description
value string? The string to parse.
result out Float256 The parsed value on success; otherwise, default.

Returns — true if parsing succeeded; otherwise, false.

TryParse(string?, IFormatProvider?, out Float256)

public static bool TryParse(string? value, IFormatProvider? provider, out Float256 result)

Attempts to parse a string with a format provider.

Parameter Type Description
value string? The string to parse.
provider IFormatProvider? An optional culture-specific format provider.
result out Float256 The parsed value on success; otherwise, default.

Returns — true if parsing succeeded; otherwise, false.

TryParse(string?, NumberStyles, IFormatProvider?, out Float256)

public static bool TryParse(string? value, NumberStyles style, IFormatProvider? provider, out Float256 result)

Attempts to parse a string with number styles and a format provider.

Parameter Type Description
value string? The string to parse.
style NumberStyles A bitwise combination of number-style flags.
provider IFormatProvider? An optional culture-specific format provider.
result out Float256 The parsed value on success; otherwise, default.

Returns — true if parsing succeeded; otherwise, false.

TryParse(ReadOnlySpan<char>, out Float256)

public static bool TryParse(ReadOnlySpan<char> value, out Float256 result)

Attempts to parse a character span using the current culture.

Parameter Type Description
value ReadOnlySpan<char> The character span to parse.
result out Float256 The parsed value on success; otherwise, default.

Returns — true if parsing succeeded; otherwise, false.

TryParse(ReadOnlySpan<char>, IFormatProvider?, out Float256)

public static bool TryParse(ReadOnlySpan<char> value, IFormatProvider? provider, out Float256 result)

Attempts to parse a character span with a format provider.

Parameter Type Description
value ReadOnlySpan<char> The character span to parse.
provider IFormatProvider? An optional culture-specific format provider.
result out Float256 The parsed value on success; otherwise, false.

Returns — true if parsing succeeded; otherwise, false.

TryParse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?, out Float256)

public static bool TryParse(ReadOnlySpan<char> value, NumberStyles style, IFormatProvider? provider, out Float256 result)

Attempts to parse a character span with number styles and a format provider.

Parameter Type Description
value ReadOnlySpan<char> The character span to parse.
style NumberStyles A bitwise combination of number-style flags.
provider IFormatProvider? An optional culture-specific format provider.
result out Float256 The parsed value on success; otherwise, default.

Returns — true if parsing succeeded; otherwise, false.

Equals(Float256, Float256)

public static bool Equals(Float256 left, Float256 right)

Determines whether two Float256 values are equal using collection-equality semantics: any two NaN bit patterns are considered equal, and positive zero equals negative zero. This matches the contract of double.Equals(double).

Parameter Type Description
left Float256 The first value.
right Float256 The second value.

Returns — true if the values are equal under collection-equality semantics; otherwise, false.


Instance Methods

Method Returns Description
CompareTo(Float256) int Compares this instance with another Float256 using the total order defined by Compare.
CompareTo(object?) int Compares this instance with another object.
Equals(Float256) bool Determines whether this instance equals another Float256 under collection-equality semantics.
Equals(object?) bool Determines whether this instance equals another object.
GetHashCode() int Returns a hash code consistent with Equals.
GetExponentByteCount() int Returns the byte count needed to serialise the exponent (always 4).
GetExponentShortestBitLength() int Returns the shortest two's-complement bit length of the current exponent.
GetSignificandBitLength() int Returns the bit length of the significand including the implicit bit (always 237).
GetSignificandByteCount() int Returns the byte count needed to serialise the significand (always 32).
TryWriteExponentBigEndian(Span&lt;byte&gt;, out int) bool Writes the exponent to a big-endian byte span.
TryWriteExponentLittleEndian(Span&lt;byte&gt;, out int) bool Writes the exponent to a little-endian byte span.
TryWriteSignificandBigEndian(Span&lt;byte&gt;, out int) bool Writes the significand (with implicit bit) to a big-endian byte span.
TryWriteSignificandLittleEndian(Span&lt;byte&gt;, out int) bool Writes the significand (with implicit bit) to a little-endian byte span.
ToString() string Returns the default string representation (G format, current culture).
ToString(string?, IFormatProvider?) string Returns the string representation using the specified format and provider.

CompareTo(Float256)

public int CompareTo(Float256 other)

Compares this instance with another Float256 value using the total order defined by Compare: NaN sorts before all numeric values; positive and negative zero compare equal.

Parameter Type Description
other Float256 The value to compare with this instance.

Returns — A negative integer if this instance precedes other; zero if equal; a positive integer if this instance follows other.

CompareTo(object?)

public int CompareTo(object? obj)

Compares this instance with another object.

Parameter Type Description
obj object? The object to compare. A null reference sorts before any Float256.

Returns — A signed ordering indicator.

Exceptions

Exception Condition
ArgumentException obj is not null and is not a Float256.

Equals(Float256)

public bool Equals(Float256 other)

Determines whether this instance is equal to other under collection-equality semantics: NaN equals NaN; positive zero equals negative zero.

Returns — true if the values are equal; otherwise, false.

Equals(object?)

public override bool Equals(object? obj)

Determines whether this instance is equal to another object.

Returns — true if obj is a Float256 that is equal to this instance; otherwise, false.

GetHashCode()

public override int GetHashCode()

Returns a hash code consistent with Equals: all NaN bit patterns share the canonical NaN hash code; positive zero and negative zero share the positive-zero hash code.

Returns — A 32-bit signed integer hash code.

GetExponentByteCount()

public int GetExponentByteCount()

Returns the number of bytes required to serialise the current exponent via TryWriteExponentBigEndian or TryWriteExponentLittleEndian.

Returns — Always returns 4 (sizeof(int)). Note that this differs from Float128, which uses a 2-byte (short) exponent; binary256's 19-bit biased exponent requires a 32-bit serialised form.

GetExponentShortestBitLength()

public int GetExponentShortestBitLength()

Returns the length in bits of the shortest two's-complement representation of the current unbiased exponent.

Returns — The shortest bit length of the unbiased exponent.

GetSignificandBitLength()

public int GetSignificandBitLength()

Returns the bit length of the full significand, including the implicit leading bit for normal values.

Returns — Always returns 237.

GetSignificandByteCount()

public int GetSignificandByteCount()

Returns the number of bytes required to serialise the significand via TryWriteSignificandBigEndian or TryWriteSignificandLittleEndian.

Returns — Always returns 32.

TryWriteExponentBigEndian(Span<byte>, out int)

public bool TryWriteExponentBigEndian(Span<byte> destination, out int bytesWritten)

Tries to write the current unbiased exponent as a big-endian signed 32-bit integer to destination.

Parameter Type Description
destination Span<byte> The target span; must be at least 4 bytes.
bytesWritten out int 4 on success; 0 if destination is too short.

Returns — true if the exponent was written successfully; otherwise, false.

TryWriteExponentLittleEndian(Span<byte>, out int)

public bool TryWriteExponentLittleEndian(Span<byte> destination, out int bytesWritten)

Tries to write the current unbiased exponent as a little-endian signed 32-bit integer to destination.

Parameter Type Description
destination Span<byte> The target span; must be at least 4 bytes.
bytesWritten out int 4 on success; 0 if destination is too short.

Returns — true if the exponent was written successfully; otherwise, false.

TryWriteSignificandBigEndian(Span<byte>, out int)

public bool TryWriteSignificandBigEndian(Span<byte> destination, out int bytesWritten)

Tries to write the 237-bit significand (with the implicit leading bit set for normal values) as a big-endian 32-byte value to destination.

Parameter Type Description
destination Span<byte> The target span; must be at least 32 bytes.
bytesWritten out int 32 on success; 0 if destination is too short.

Returns — true if the significand was written successfully; otherwise, false.

TryWriteSignificandLittleEndian(Span<byte>, out int)

public bool TryWriteSignificandLittleEndian(Span<byte> destination, out int bytesWritten)

Tries to write the 237-bit significand as a little-endian 32-byte value to destination.

Parameter Type Description
destination Span<byte> The target span; must be at least 32 bytes.
bytesWritten out int 32 on success; 0 if destination is too short.

Returns — true if the significand was written successfully; otherwise, false.

ToString()

public override string ToString()

Returns the string representation of the current value using the G (general) format and the current culture. NaN, positive infinity, and negative infinity are rendered as the corresponding symbols from the current culture's NumberFormatInfo. The round-trip digit count for binary256 is 73.

Returns — A string representation of the current value.

ToString(string?, IFormatProvider?)

public string ToString(string? format, IFormatProvider? formatProvider = null)

Returns the string representation using the specified format and format provider. The G and R specifiers produce a round-trip representation with up to 73 significant digits, for values of any magnitude, including values whose integer part has more digits than the requested precision; precision-bearing specifiers (N, F, C, P, etc.) route through NumberInfo for correct padding and grouping. NaN and infinity symbols are always sourced from the NumberFormatInfo of the supplied provider.

Note The round-trip output does not always parse back to exactly the same bits: some values come back a few units in the last place out.

Parameter Type Description
format string? A standard numeric format string, or null for the default G format.
formatProvider IFormatProvider? An optional culture-specific format provider.

Returns — The formatted string.

Operators

Arithmetic Operators

Operator Returns Description
operator +(Float256) Float256 Unary plus; returns the operand unchanged.
operator -(Float256) Float256 Unary negation; flips the sign bit.
operator ++(Float256) Float256 Adds one; correctly rounded.
operator --(Float256) Float256 Subtracts one; correctly rounded.
operator +(Float256, Float256) Float256 IEEE 754 addition.
operator -(Float256, Float256) Float256 IEEE 754 subtraction.
operator *(Float256, Float256) Float256 IEEE 754 multiplication.
operator /(Float256, Float256) Float256 IEEE 754 division.
operator %(Float256, Float256) Float256 Truncating remainder (C# % semantics).

Bitwise Operators

Operator Returns Description
operator &(Float256, Float256) Float256 Bitwise AND of the raw bit patterns.
operator |(Float256, Float256) Float256 Bitwise OR of the raw bit patterns.
operator ^(Float256, Float256) Float256 Bitwise XOR of the raw bit patterns.
operator ~(Float256) Float256 Bitwise complement of the raw bit pattern.

Comparison Operators

Operator Returns Description
operator ==(Float256, Float256) bool IEEE 754 equality; false if either operand is NaN.
operator !=(Float256, Float256) bool IEEE 754 inequality; true if either operand is NaN.
operator <(Float256, Float256) bool Less-than; false if either operand is NaN.
operator <=(Float256, Float256) bool Less-than-or-equal; false if either operand is NaN.
operator >(Float256, Float256) bool Greater-than; false if either operand is NaN.
operator >=(Float256, Float256) bool Greater-than-or-equal; false if either operand is NaN.

Implicit Conversion Operators (to Float256)

Operator Description
implicit operator Float256(sbyte) Widens a signed byte; exact.
implicit operator Float256(byte) Widens an unsigned byte; exact.
implicit operator Float256(short) Widens a 16-bit signed integer; exact.
implicit operator Float256(ushort) Widens a 16-bit unsigned integer; exact.
implicit operator Float256(int) Widens a 32-bit signed integer; exact.
implicit operator Float256(uint) Widens a 32-bit unsigned integer; exact.
implicit operator Float256(long) Widens a 64-bit signed integer; exact.
implicit operator Float256(ulong) Widens a 64-bit unsigned integer; exact.
implicit operator Float256(Int128) Widens a 128-bit signed integer; exact (128-bit value fits in 237-bit significand).
implicit operator Float256(UInt128) Widens a 128-bit unsigned integer; exact (128-bit value fits in 237-bit significand).
implicit operator Float256(char) Widens a char code-point; exact.
implicit operator Float256(Half) Widens a Half; exact (11-bit significand fits in 237 bits).
implicit operator Float256(float) Widens a float; exact (24-bit significand fits in 237 bits), preserving NaN payloads, infinities and subnormals.
implicit operator Float256(double) Widens a double; exact (53-bit significand fits in 237 bits), preserving NaN payloads, infinities and subnormals.
implicit operator Float256(decimal) Converts a decimal; exact (96-bit significand fits in 237 bits).
implicit operator Float256(Float128) Widens a Float128; exact (every binary128 value is representable in binary256).

Explicit Conversion Operators (from Float256)

Operator Description
explicit operator sbyte(Float256) Truncates toward zero; saturates on overflow; returns 0 for NaN.
explicit operator checked sbyte(Float256) Throws OverflowException for NaN, infinity, or out-of-range.
explicit operator byte(Float256) Truncates toward zero; saturates on overflow; returns 0 for NaN.
explicit operator checked byte(Float256) Throws OverflowException for NaN, infinity, negative, or out-of-range.
explicit operator short(Float256) Truncates toward zero; saturates on overflow; returns 0 for NaN.
explicit operator checked short(Float256) Throws OverflowException for NaN, infinity, or out-of-range.
explicit operator ushort(Float256) Truncates toward zero; saturates on overflow; returns 0 for NaN.
explicit operator checked ushort(Float256) Throws OverflowException for NaN, infinity, negative, or out-of-range.
explicit operator int(Float256) Truncates toward zero; saturates on overflow; returns 0 for NaN.
explicit operator checked int(Float256) Throws OverflowException for NaN, infinity, or out-of-range.
explicit operator uint(Float256) Truncates toward zero; saturates on overflow; returns 0 for NaN.
explicit operator checked uint(Float256) Throws OverflowException for NaN, infinity, negative, or out-of-range.
explicit operator long(Float256) Truncates toward zero; saturates on overflow; returns 0 for NaN.
explicit operator checked long(Float256) Throws OverflowException for NaN, infinity, or out-of-range.
explicit operator ulong(Float256) Truncates toward zero; saturates on overflow; returns 0 for NaN.
explicit operator checked ulong(Float256) Throws OverflowException for NaN, infinity, negative, or out-of-range.
explicit operator Int128(Float256) Truncates toward zero; saturates on overflow; returns Int128.Zero for NaN.
explicit operator checked Int128(Float256) Throws OverflowException for NaN, infinity, or out-of-range.
explicit operator UInt128(Float256) Truncates toward zero; saturates on overflow; returns UInt128.Zero for NaN or negative.
explicit operator checked UInt128(Float256) Throws OverflowException for NaN, infinity, negative, or out-of-range.
explicit operator char(Float256) Truncates toward zero; saturates on overflow; returns (char)0 for NaN.
explicit operator checked char(Float256) Throws OverflowException for NaN, infinity, negative, or out-of-range.
explicit operator BigInteger(Float256) Truncates toward zero; exact for any finite integer; throws OverflowException for NaN or infinity.
explicit operator Half(Float256) Converts to the nearest Half (via double); may lose precision.
explicit operator float(Float256) Converts to the nearest float (via double); may lose precision.
explicit operator double(Float256) Converts to the nearest double; rounds to nearest, ties-to-even, saturating to ±infinity on overflow.
explicit operator decimal(Float256) Converts exactly from the binary significand and exponent, rounding once to nearest, ties-to-even, at the largest scale (up to 28) whose rounded 96-bit mantissa fits; trailing fractional zeros are removed, so the result carries its shortest scale. Magnitudes below 0.5E-28 (and negative zero) convert to 0. The result is the same on every target framework, and decimal values with up to 29 significant digits round-trip (for example, (decimal)(Float256)0.1m is 0.1m). Throws OverflowException for NaN, infinity, or once the magnitude rounds to 2^96.
explicit operator BigDecimal(Float256) Converts to an exact BigDecimal; throws OverflowException for NaN or infinity.
explicit operator Float256(BigDecimal) Converts a BigDecimal to the nearest Float256; saturates to ±infinity on overflow.
explicit operator Float256(BigInteger) Converts a BigInteger to the nearest Float256; saturates to ±infinity on overflow.
explicit operator Float128(Float256) Narrows to Float128; rounds to nearest, ties-to-even; saturates to ±infinity on overflow.

operator +(Float256) (unary)

public static Float256 operator +(Float256 value)

Returns value unchanged (identity operation).

operator -(Float256) (unary)

public static Float256 operator -(Float256 value)

Returns the negation of value by flipping the sign bit. Applies to all values including NaN and zero.

operator ++(Float256) (increment)

public static Float256 operator ++(Float256 value)

Returns value + 1, correctly rounded to nearest, ties-to-even.

operator --(Float256) (decrement)

public static Float256 operator --(Float256 value)

Returns value - 1, correctly rounded to nearest, ties-to-even.

operator +(Float256, Float256)

public static Float256 operator +(Float256 left, Float256 right)

Computes the IEEE 754 sum of left and right.

operator -(Float256, Float256)

public static Float256 operator -(Float256 left, Float256 right)

Computes the IEEE 754 difference of left and right.

operator *(Float256, Float256)

public static Float256 operator *(Float256 left, Float256 right)

Computes the IEEE 754 product of left and right.

operator /(Float256, Float256)

public static Float256 operator /(Float256 left, Float256 right)

Computes the IEEE 754 quotient of left and right.

operator %(Float256, Float256)

public static Float256 operator %(Float256 left, Float256 right)

Computes the truncating remainder of left divided by right (C# % semantics; the result has the same sign as left).

operator &(Float256, Float256)

public static Float256 operator &(Float256 left, Float256 right)

Returns the bitwise AND of the raw bit patterns of left and right. This is a raw bit manipulation; the result is not generally a meaningful floating-point value.

operator |(Float256, Float256)

public static Float256 operator |(Float256 left, Float256 right)

Returns the bitwise OR of the raw bit patterns of left and right.

operator ^(Float256, Float256)

public static Float256 operator ^(Float256 left, Float256 right)

Returns the bitwise XOR of the raw bit patterns of left and right.

operator ~(Float256) (bitwise complement)

public static Float256 operator ~(Float256 value)

Returns the bitwise complement of the raw bit pattern of value. The result is AllBitsSet when value is Zero.

operator ==(Float256, Float256)

public static bool operator ==(Float256 left, Float256 right)

Returns true when left and right are equal under IEEE 754 semantics: NaN is never equal to any value (including itself); positive zero equals negative zero.

operator !=(Float256, Float256)

public static bool operator !=(Float256 left, Float256 right)

Returns true when left and right are not equal under IEEE 754 semantics. Returns true when either operand is NaN.

operator <(Float256, Float256)

public static bool operator <(Float256 left, Float256 right)

Returns true when left is strictly less than right. Returns false if either operand is NaN.

operator <=(Float256, Float256)

public static bool operator <=(Float256 left, Float256 right)

Returns true when left is less than or equal to right. Returns false if either operand is NaN.

operator >(Float256, Float256)

public static bool operator >(Float256 left, Float256 right)

Returns true when left is strictly greater than right. Returns false if either operand is NaN.

operator >=(Float256, Float256)

public static bool operator >=(Float256 left, Float256 right)

Returns true when left is greater than or equal to right. Returns false if either operand is NaN.

See Also

ONIXLabs .NET Library


Clone this wiki locally