Repository navigation
OnixLabs.Numerics.Float256
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
|
public readonly partial struct Float256 :
IBinaryFloatingPointIeee754<Float256>,
IMinMaxValue<Float256>,
IValueEquatable<Float256>,
IValueComparable<Float256>,
IConvertibleFloat256 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.
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 subnormalusing 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 _);| 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. |
public static Float256 Zero { get; }Gets the Float256 value representing positive zero. This is the default value of the struct.
public static Float256 NegativeZero { get; }Gets the Float256 value representing negative zero. Negative zero compares equal to positive zero under IEEE 754 ordering semantics.
public static Float256 One { get; }Gets the Float256 value representing positive one.
public static Float256 NegativeOne { get; }Gets the Float256 value representing negative one.
public static Float256 Two { get; }Gets the Float256 value representing the integer two.
public static Float256 Ten { get; }Gets the Float256 value representing the integer ten.
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⁻⁷⁸⁹⁸⁴.
public static Float256 MaxValue { get; }Gets the largest finite positive Float256 value. Approximately 1.61 × 10⁷⁸⁹¹³.
public static Float256 MinValue { get; }Gets the smallest finite negative Float256 value (the most negative finite number). Equal to −MaxValue.
public static Float256 PositiveInfinity { get; }Gets the Float256 value representing positive infinity.
public static Float256 NegativeInfinity { get; }Gets the Float256 value representing negative infinity.
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.
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.
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.
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.
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.
| Constructor | Description |
|---|---|
Float256(UInt256) |
Initializes a new instance from the specified raw IEEE 754 binary256 bit pattern. |
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. |
| Property | Type | Description |
|---|---|---|
Bits |
UInt256 |
Gets the raw IEEE 754 binary256 bit pattern of the current value. |
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.
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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) / π. |
| 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]. |
| Method | Returns | Description |
|---|---|---|
Parse(string, IFormatProvider?) |
Float256 |
Parses a string. |
Parse(string, NumberStyles, IFormatProvider?) |
Float256 |
Parses a string with explicit number styles. |
Parse(ReadOnlySpan<char>, IFormatProvider?) |
Float256 |
Parses a character span. |
Parse(ReadOnlySpan<char>, 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<char>, out Float256) |
bool |
Attempts to parse a character span; returns false on failure. |
TryParse(ReadOnlySpan<char>, IFormatProvider?, out Float256) |
bool |
Attempts to parse a character span with a format provider. |
TryParse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?, out Float256) |
bool |
Attempts to parse a character span with number styles and a format provider. |
| Method | Returns | Description |
|---|---|---|
Equals(Float256, Float256) |
bool |
Determines whether two Float256 values are equal under collection-equality semantics. |
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.
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.
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. |
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.
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.
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.
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.
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.
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 × ∞.
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).
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.
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.
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.
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.
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.
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.
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. |
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. |
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.
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.
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.
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.
public static Float256 MaxNumber(Float256 x, Float256 y)Returns the larger of two values, treating NaN as missing.
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.
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.
public static Float256 MinMagnitudeNumber(Float256 x, Float256 y)Returns the value with the smaller absolute magnitude; treats NaN as missing.
public static Float256 MaxMagnitudeNumber(Float256 x, Float256 y)Returns the value with the larger absolute magnitude; treats NaN as missing.
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.
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.
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.
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.
public static Float256 ReciprocalEstimate(Float256 value)Returns the correctly-rounded quotient 1 / value.
public static Float256 ReciprocalSqrtEstimate(Float256 value)Returns an approximation of 1 / √value, faithful to within 1 ULP (inheriting the accuracy of Sqrt).
public static bool IsNaN(Float256 value)Returns true when value is a not-a-number (NaN) value.
public static bool IsInfinity(Float256 value)Returns true when value is positive or negative infinity.
public static bool IsPositiveInfinity(Float256 value)Returns true when value is positive infinity.
public static bool IsNegativeInfinity(Float256 value)Returns true when value is negative infinity.
public static bool IsFinite(Float256 value)Returns true when value is finite (not NaN and not infinity).
public static bool IsNormal(Float256 value)Returns true when value is a normal value — finite, non-zero, and not subnormal.
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).
public static bool IsZero(Float256 value)Returns true when value is positive zero or negative zero.
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.
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.
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.
public static bool IsEvenInteger(Float256 value)Returns true when value is a finite even integer.
public static bool IsOddInteger(Float256 value)Returns true when value is a finite odd integer.
public static bool IsPow2(Float256 value)Returns true when value is a positive integer that is an exact power of two.
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.
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.
public static Float256 Exp10(Float256 value)Computes 10^value via Exp(value × ln 10). Returns NaN for NaN; PositiveInfinity on overflow; Zero on underflow.
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.
public static Float256 Exp2M1(Float256 value)Computes 2^value − 1, accurate near zero. Returns NegativeOne for negative infinity.
public static Float256 Exp10M1(Float256 value)Computes 10^value − 1, accurate near zero. Returns NegativeOne for negative infinity.
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.
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.
public static Float256 Log10(Float256 value)Computes the base-10 logarithm of value. Returns NaN for negative inputs and NaN; NegativeInfinity for zero.
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).
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.
public static Float256 Log2P1(Float256 value)Computes log2(1 + value), accurate near zero.
public static Float256 Log10P1(Float256 value)Computes log10(1 + value), accurate near zero.
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.
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.
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.
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.
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.
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.
public static Float256 Cos(Float256 value)Computes the cosine of value (angle in radians). Returns NaN for NaN or infinity; returns One for zero.
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.
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).
public static Float256 SinPi(Float256 value)Computes sin(π · value). Returns exact zero for integer arguments.
public static Float256 CosPi(Float256 value)Computes cos(π · value). Returns One for zero.
public static Float256 TanPi(Float256 value)Computes tan(π · value). Returns exact zero for integer arguments.
public static (Float256 SinPi, Float256 CosPi) SinCosPi(Float256 value)Computes sin(π · value) and cos(π · value) simultaneously.
Returns — A tuple (SinPi, CosPi).
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.
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.
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.
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.
public static Float256 AsinPi(Float256 value)Computes Asin(value) / π.
public static Float256 AcosPi(Float256 value)Computes Acos(value) / π.
public static Float256 AtanPi(Float256 value)Computes Atan(value) / π; returns ±½ for ±infinity.
public static Float256 Atan2Pi(Float256 y, Float256 x)Computes Atan2(y, x) / π, resolving all four quadrants.
public static Float256 Sinh(Float256 value)Computes the hyperbolic sine of value. Preserves the sign of zero; returns ±infinity for ±infinity or on overflow.
public static Float256 Cosh(Float256 value)Computes the hyperbolic cosine of value. Returns One for zero; PositiveInfinity for ±infinity or on overflow.
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.
public static Float256 Asinh(Float256 value)Computes the inverse hyperbolic sine of value. Preserves the sign of zero; returns ±infinity for ±infinity.
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.
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.
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. |
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. |
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. |
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. |
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.
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.
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.
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.
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.
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.
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.
| 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<byte>, out int) |
bool |
Writes the exponent to a big-endian byte span. |
TryWriteExponentLittleEndian(Span<byte>, out int) |
bool |
Writes the exponent to a little-endian byte span. |
TryWriteSignificandBigEndian(Span<byte>, out int) |
bool |
Writes the significand (with implicit bit) to a big-endian byte span. |
TryWriteSignificandLittleEndian(Span<byte>, 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. |
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.
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. |
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.
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.
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.
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.
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.
public int GetSignificandBitLength()Returns the bit length of the full significand, including the implicit leading bit for normal values.
Returns — Always returns 237.
public int GetSignificandByteCount()Returns the number of bytes required to serialise the significand via TryWriteSignificandBigEndian or TryWriteSignificandLittleEndian.
Returns — Always returns 32.
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.
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.
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.
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.
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.
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.
| 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). |
| 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. |
| 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. |
| 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). |
| 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. |
public static Float256 operator +(Float256 value)Returns value unchanged (identity operation).
public static Float256 operator -(Float256 value)Returns the negation of value by flipping the sign bit. Applies to all values including NaN and zero.
public static Float256 operator ++(Float256 value)Returns value + 1, correctly rounded to nearest, ties-to-even.
public static Float256 operator --(Float256 value)Returns value - 1, correctly rounded to nearest, ties-to-even.
public static Float256 operator +(Float256 left, Float256 right)Computes the IEEE 754 sum of left and right.
public static Float256 operator -(Float256 left, Float256 right)Computes the IEEE 754 difference of left and right.
public static Float256 operator *(Float256 left, Float256 right)Computes the IEEE 754 product of left and right.
public static Float256 operator /(Float256 left, Float256 right)Computes the IEEE 754 quotient of left and right.
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).
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.
public static Float256 operator |(Float256 left, Float256 right)Returns the bitwise OR of the raw bit patterns of left and right.
public static Float256 operator ^(Float256 left, Float256 right)Returns the bitwise XOR of the raw bit patterns of left and right.
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.
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.
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.
public static bool operator <(Float256 left, Float256 right)Returns true when left is strictly less than right. Returns false if either operand is NaN.
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.
public static bool operator >(Float256 left, Float256 right)Returns true when left is strictly greater than right. Returns false if either operand is NaN.
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.
ONIXLabs .NET Library · Repository · NuGet · License (Apache-2.0)
Copyright © ONIXLabs 2020. Licensed under the Apache License, Version 2.0.
- Enumeration<T>
- Optional<T>
- OptionalEqualityComparer<T>
- OptionalExtensions
- Result
- Result<T>
- ResultEqualityComparer<T>
- ResultExtensions
- Specification<T>
- Preconditions
- IValueEquatable<T>
- IValueComparable<T>
- IBinaryConvertible
- ISpanBinaryConvertible
- IMemoryBinaryConvertible
- ArrayExtensions
- ComparableExtensions
- DateTimeExtensions
- ISpanParsableExtensions
- ObjectExtensions
- RandomExtensions
- ReadOnlySequenceExtensions
- ReadOnlySpanExtensions
- StringExtensions
- Base16
- Base32
- Base58
- Base64
- IBaseCodec
- IBaseValue
- IBaseValue<T>
- Base16Codec
- Base32Codec
- Base58Codec
- Base64Codec
- Base16FormatProvider
- Base32FormatProvider
- Base58FormatProvider
- Base64FormatProvider
- EncodingExtensions
- ReadOnlySpanExtensions
- StringBuilderExtensions
- BigDecimal
- BigDecimalEqualityComparer
- BigDecimalOrdinalityComparer
- NumberInfo
- NumberInfoEqualityComparer
- NumberInfoOrdinalityComparer
- Int256
- Int512
- UInt256
- UInt512
- Float128
- Float256
- GenericMath
- NumericsExtensions
- ConversionMode
- ScaleMode
- Hash
- NamedHash
- Sha3
- Sha3Hash224
- Sha3Hash256
- Sha3Hash384
- Sha3Hash512
- Sha3Shake128
- Sha3Shake256
- MerkleTree
- MerkleTree<T>
- PrivateKey
- PublicKey
- NamedPrivateKey
- NamedPublicKey
- EcdhPrivateKey
- EcdhPublicKey
- EcdsaPrivateKey
- EcdsaPublicKey
- EddsaPrivateKey
- EddsaPublicKey
- RsaPrivateKey
- RsaPublicKey
- DigitalSignature
- DigitalSignatureAndPublicKey
- Salt
- Secret
- ICryptoPrimitive<T>
- IHashable
- IEcdhPrivateKey
- IEcdsaPrivateKey
- IEddsaPrivateKey
- IRsaPrivateKey
- IPrivateKeyDerivable<T>
- IPrivateKeyExportable
- IPrivateKeyImportable<T>
- IPrivateKeyPemImportable<T>
- IPrivateKeyPkcs8Exportable
- IPrivateKeyPkcs8Importable<T>
- IPrivateKeyPkcs8PemExportable
- IPrivateKeyRawExportable
- IPrivateKeyRawImportable<T>
- IPrivateKeyRawPemExportable
- IEcdhPublicKey
- IEcdsaPublicKey
- IEddsaPublicKey
- IRsaPublicKey
- IPublicKeyExportable
- IPublicKeyImportable<T>
- IPublicKeyPemExportable
- IPublicKeyPemImportable<T>
- IPublicKeyRawExportable
- IPublicKeyRawImportable<T>
- HashAlgorithmExtensions
- ReadOnlySpanExtensions