Repository navigation
OnixLabs.Numerics.Float128
Represents an IEEE 754 binary128 quadruple-precision floating-point number with a 113-bit significand, a 15-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 → Float128
|
| Implements |
IBinaryFloatingPointIeee754<Float128>, IMinMaxValue<Float128>, IValueEquatable<Float128>, IValueComparable<Float128>, IConvertible
|
public readonly partial struct Float128 :
IBinaryFloatingPointIeee754<Float128>,
IMinMaxValue<Float128>,
IValueEquatable<Float128>,
IValueComparable<Float128>,
IConvertibleFloat128 implements the IEEE 754-2008 binary128 format (also called quadruple precision). The 128-bit bit pattern is laid out as one sign bit, a 15-bit biased exponent (bias 16383), and a 112-bit trailing significand. For normal values an implicit leading one gives 113 significant bits of precision, which corresponds to approximately 33–36 significant decimal digits and supports finite values up to roughly ±1.19 × 10⁴⁹³². The smallest positive subnormal is approximately 3.36 × 10⁻⁴⁹⁵¹.
NaN and infinity — Float128 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(Float128) 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 128-bit arithmetic. FusedMultiplyAdd is a true single-rounded FMA computed in a 512-bit accumulator.
Generic-math support — because Float128 implements IBinaryFloatingPointIeee754<Float128> it participates fully in .NET's generic-math infrastructure. Any algorithm constrained to IFloatingPoint<T>, INumber<T>, or INumberBase<T> accepts Float128 without modification. Explicitly-implemented interface members (INumberBase<Float128>.IsCanonical, INumberBase<Float128>.IsComplexNumber, etc.) are accessible via the interface and are not listed in the member tables.
Transcendental functions — Float128 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. 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. Every source value is converted exactly when precision permits; wider integer types are rounded to nearest.
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 binary128 is 36.
Serialisation — the floating-point exponent and significand can be written to byte spans individually in either endianness via TryWriteExponentBigEndian, TryWriteExponentLittleEndian, TryWriteSignificandBigEndian, and TryWriteSignificandLittleEndian.
Relationship to siblings — Float128 and Float256 share a symmetric public API. Float256 offers double the bit width (237-bit significand) and is used internally by Float128.ToString as a high-precision intermediate during the binary-to-decimal conversion.
using OnixLabs.Numerics;
Float128 a = Float128.Parse("1.23456789012345678901234567890123456789");
Float128 b = (Float128)3.14159265358979323846264338327950288; // implicit from double
Float128 sum = a + b;
Float128 prod = a * b;
Float128 quot = a / b;
Console.WriteLine(Float128.IsFinite(sum)); // True
Console.WriteLine(Float128.IsNaN(Float128.NaN)); // True
Console.WriteLine(Float128.MaxValue); // ~1.189731495357231765085759326628E+4932
Console.WriteLine(Float128.Epsilon); // smallest positive subnormalusing OnixLabs.Numerics;
using System.Globalization;
Float128 angle = Float128.Pi / (Float128)4;
Float128 sinVal = Float128.Sin(angle); // ~0.70710678118654752440...
Float128 logVal = Float128.Log(Float128.E); // 1 (exactly)
Float128 sqrtTwo = Float128.Sqrt((Float128)2);
// Round-trip: 36 significant decimal digits
string rt = sqrtTwo.ToString("G", CultureInfo.InvariantCulture);
Float128 parsed = Float128.Parse(rt, CultureInfo.InvariantCulture);
Console.WriteLine(parsed == sqrtTwo); // True
// Precision-bearing format
Console.WriteLine(sinVal.ToString("N10", CultureInfo.InvariantCulture));
// 0.7071067812
// Serialise the exponent and significand
Span<byte> expBuf = stackalloc byte[2];
sqrtTwo.TryWriteExponentBigEndian(expBuf, out _);
Span<byte> sigBuf = stackalloc byte[16];
sqrtTwo.TryWriteSignificandBigEndian(sigBuf, out _);| Member | Type | Description |
|---|---|---|
Zero |
Float128 |
Positive zero (+0). |
NegativeZero |
Float128 |
Negative zero (−0). |
One |
Float128 |
The value one. |
NegativeOne |
Float128 |
The value negative one. |
Two |
Float128 |
The value two. |
Ten |
Float128 |
The value ten. |
Epsilon |
Float128 |
The smallest positive subnormal (least positive value). |
MaxValue |
Float128 |
The largest finite positive value. |
MinValue |
Float128 |
The smallest finite negative value (most negative). |
PositiveInfinity |
Float128 |
Positive infinity. |
NegativeInfinity |
Float128 |
Negative infinity. |
NaN |
Float128 |
The canonical quiet not-a-number value. |
AllBitsSet |
Float128 |
All 128 bits set (a negative NaN). |
E |
Float128 |
Euler's number, rounded to binary128 precision. |
Pi |
Float128 |
The ratio π of a circle's circumference to its diameter, rounded to binary128 precision. |
Tau |
Float128 |
The number of radians in one turn (2π), rounded to binary128 precision. |
public static Float128 Zero { get; }Gets the Float128 value representing positive zero. This is the default value of the struct.
public static Float128 NegativeZero { get; }Gets the Float128 value representing negative zero. Negative zero compares equal to positive zero under IEEE 754 ordering semantics.
public static Float128 One { get; }Gets the Float128 value representing positive one.
public static Float128 NegativeOne { get; }Gets the Float128 value representing negative one.
public static Float128 Two { get; }Gets the Float128 value representing the integer two.
public static Float128 Ten { get; }Gets the Float128 value representing the integer ten.
public static Float128 Epsilon { get; }Gets the smallest positive finite Float128 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 UInt128.One. Approximately 3.36 × 10⁻⁴⁹⁵¹.
public static Float128 MaxValue { get; }Gets the largest finite positive Float128 value. Approximately 1.19 × 10⁴⁹³².
public static Float128 MinValue { get; }Gets the smallest finite negative Float128 value (the most negative finite number). Equal to −MaxValue.
public static Float128 PositiveInfinity { get; }Gets the Float128 value representing positive infinity.
public static Float128 NegativeInfinity { get; }Gets the Float128 value representing negative infinity.
public static Float128 NaN { get; }Gets the canonical quiet not-a-number (NaN) Float128 value. All arithmetic operations that receive a NaN operand propagate NaN as the result.
public static Float128 AllBitsSet { get; }Gets the Float128 value whose entire 128-bit pattern is ones. The bit pattern equals UInt128.MaxValue; this encodes a negative NaN.
public static Float128 E { get; }Gets the natural logarithmic base (Euler's number, e ≈ 2.71828…), parsed from a 40-significant-digit decimal literal to guarantee a bit-correct binary128 result.
public static Float128 Pi { get; }Gets the ratio of the circumference of a circle to its diameter (π ≈ 3.14159…), parsed from a 40-significant-digit decimal literal to guarantee a bit-correct binary128 result.
public static Float128 Tau { get; }Gets the number of radians in one full turn (τ = 2π ≈ 6.28318…), parsed from a 40-significant-digit decimal literal to guarantee a bit-correct binary128 result.
| Constructor | Description |
|---|---|
Float128(UInt128) |
Initializes a new instance from the specified raw IEEE 754 binary128 bit pattern. |
public Float128(UInt128 bits)Initializes a new instance of the Float128 struct from the specified raw IEEE 754 binary128 bit pattern.
| Parameter | Type | Description |
|---|---|---|
bits |
UInt128 |
The raw 128-bit IEEE 754 binary128 bit pattern. |
| Property | Type | Description |
|---|---|---|
Bits |
UInt128 |
Gets the raw IEEE 754 binary128 bit pattern of the current value. |
public UInt128 Bits { get; }Gets the raw 128-bit IEEE 754 binary128 representation of the current Float128 value. This property provides direct access to the bit pattern for low-level manipulation, serialisation, or construction of derived values.
| Method | Returns | Description |
|---|---|---|
Abs(Float128) |
Float128 |
Returns the absolute value, preserving NaN payloads. |
Negate(Float128) |
Float128 |
Returns the unary negation of the value. |
Sign(Float128) |
int |
Returns −1, 0, or 1 indicating the sign. |
Add(Float128, Float128) |
Float128 |
Computes the IEEE 754 round-to-nearest sum. |
Subtract(Float128, Float128) |
Float128 |
Computes the IEEE 754 round-to-nearest difference. |
Multiply(Float128, Float128) |
Float128 |
Computes the IEEE 754 round-to-nearest product. |
Divide(Float128, Float128) |
Float128 |
Computes the IEEE 754 round-to-nearest quotient. |
Modulus(Float128, Float128) |
Float128 |
Computes the truncating remainder. |
FusedMultiplyAdd(Float128, Float128, Float128) |
Float128 |
Computes (left × right) + addend with a single final rounding. |
Ieee754Remainder(Float128, Float128) |
Float128 |
Computes the IEEE 754 remainder using round-to-nearest-even on the quotient. |
CopySign(Float128, Float128) |
Float128 |
Returns a value with the magnitude of magnitude and the sign of sign. |
| Method | Returns | Description |
|---|---|---|
Ceiling(Float128) |
Float128 |
Rounds toward positive infinity. |
Floor(Float128) |
Float128 |
Rounds toward negative infinity. |
Truncate(Float128) |
Float128 |
Rounds toward zero. |
Round(Float128) |
Float128 |
Rounds to the nearest integer; ties to even. |
Round(Float128, int) |
Float128 |
Rounds to a specified number of digits; ties to even. |
Round(Float128, MidpointRounding) |
Float128 |
Rounds to the nearest integer using the specified midpoint strategy. |
Round(Float128, int, MidpointRounding) |
Float128 |
Rounds to a specified number of digits using the specified midpoint strategy. |
| Method | Returns | Description |
|---|---|---|
Compare(Float128, Float128) |
int |
Imposes a total order; NaN sorts before all numeric values. |
Min(Float128, Float128) |
Float128 |
Returns the smaller of two values; propagates NaN. |
Max(Float128, Float128) |
Float128 |
Returns the larger of two values; propagates NaN. |
MinNumber(Float128, Float128) |
Float128 |
Returns the smaller value; treats NaN as missing. |
MaxNumber(Float128, Float128) |
Float128 |
Returns the larger value; treats NaN as missing. |
MinMagnitude(Float128, Float128) |
Float128 |
Returns the value with the smaller absolute magnitude; propagates NaN. |
MaxMagnitude(Float128, Float128) |
Float128 |
Returns the value with the larger absolute magnitude; propagates NaN. |
MinMagnitudeNumber(Float128, Float128) |
Float128 |
Returns the value with the smaller absolute magnitude; treats NaN as missing. |
MaxMagnitudeNumber(Float128, Float128) |
Float128 |
Returns the value with the larger absolute magnitude; treats NaN as missing. |
| Method | Returns | Description |
|---|---|---|
ILogB(Float128) |
int |
Returns the unbiased binary exponent; int.MaxValue for NaN/infinity; int.MinValue for zero. |
ScaleB(Float128, int) |
Float128 |
Returns value × 2^n, saturating to infinity on overflow and to zero on underflow. |
BitIncrement(Float128) |
Float128 |
Returns the next representable value above the argument. |
BitDecrement(Float128) |
Float128 |
Returns the next representable value below the argument. |
ReciprocalEstimate(Float128) |
Float128 |
Returns the correctly-rounded quotient 1 / value. |
ReciprocalSqrtEstimate(Float128) |
Float128 |
Returns an approximation of 1 / √value, faithful to within 1 ULP. |
| Method | Returns | Description |
|---|---|---|
IsNaN(Float128) |
bool |
Returns true when the value is NaN. |
IsInfinity(Float128) |
bool |
Returns true when the value is positive or negative infinity. |
IsPositiveInfinity(Float128) |
bool |
Returns true when the value is positive infinity. |
IsNegativeInfinity(Float128) |
bool |
Returns true when the value is negative infinity. |
IsFinite(Float128) |
bool |
Returns true when the value is finite (not NaN, not infinity). |
IsNormal(Float128) |
bool |
Returns true when the value is a normal (non-zero, non-subnormal, non-infinite, non-NaN) value. |
IsSubnormal(Float128) |
bool |
Returns true when the value is a non-zero subnormal. |
IsZero(Float128) |
bool |
Returns true when the value is positive or negative zero. |
IsNegative(Float128) |
bool |
Returns true when the sign bit is set (including negative zero and negative NaN). |
IsPositive(Float128) |
bool |
Returns true when the sign bit is clear (including positive zero and canonical NaN). |
IsInteger(Float128) |
bool |
Returns true when the value is a finite integer. |
IsEvenInteger(Float128) |
bool |
Returns true when the value is an even finite integer. |
IsOddInteger(Float128) |
bool |
Returns true when the value is an odd finite integer. |
IsPow2(Float128) |
bool |
Returns true when the value is a positive power of two. |
| Method | Returns | Description |
|---|---|---|
Exp(Float128) |
Float128 |
Computes e^value. |
Exp2(Float128) |
Float128 |
Computes 2^value. |
Exp10(Float128) |
Float128 |
Computes 10^value. |
ExpM1(Float128) |
Float128 |
Computes e^value − 1, accurate near zero. |
Exp2M1(Float128) |
Float128 |
Computes 2^value − 1, accurate near zero. |
Exp10M1(Float128) |
Float128 |
Computes 10^value − 1, accurate near zero. |
| Method | Returns | Description |
|---|---|---|
Log(Float128) |
Float128 |
Computes the natural logarithm. |
Log2(Float128) |
Float128 |
Computes the base-2 logarithm. |
Log10(Float128) |
Float128 |
Computes the base-10 logarithm. |
Log(Float128, Float128) |
Float128 |
Computes the logarithm in a specified base. |
LogP1(Float128) |
Float128 |
Computes ln(1 + value), accurate near zero. |
Log2P1(Float128) |
Float128 |
Computes log2(1 + value), accurate near zero. |
Log10P1(Float128) |
Float128 |
Computes log10(1 + value), accurate near zero. |
| Method | Returns | Description |
|---|---|---|
Pow(Float128, Float128) |
Float128 |
Computes x^y following IEEE 754-2019 special-case rules. |
Sqrt(Float128) |
Float128 |
Computes the square root; faithful to within 1 ULP. |
Cbrt(Float128) |
Float128 |
Computes the cube root; preserves the sign of negative inputs. |
RootN(Float128, int) |
Float128 |
Computes the _n_th root. |
Hypot(Float128, Float128) |
Float128 |
Computes √(x² + y²), avoiding intermediate overflow. |
| Method | Returns | Description |
|---|---|---|
Sin(Float128) |
Float128 |
Computes the sine of an angle in radians. |
Cos(Float128) |
Float128 |
Computes the cosine of an angle in radians. |
Tan(Float128) |
Float128 |
Computes the tangent of an angle in radians. |
SinCos(Float128) |
(Float128 Sin, Float128 Cos) |
Computes sine and cosine simultaneously. |
SinPi(Float128) |
Float128 |
Computes sin(π · value). |
CosPi(Float128) |
Float128 |
Computes cos(π · value). |
TanPi(Float128) |
Float128 |
Computes tan(π · value). |
SinCosPi(Float128) |
(Float128 SinPi, Float128 CosPi) |
Computes sin(π · value) and cos(π · value) simultaneously. |
| Method | Returns | Description |
|---|---|---|
Asin(Float128) |
Float128 |
Computes the arcsine; input in [−1, 1]; result in radians. |
Acos(Float128) |
Float128 |
Computes the arccosine; input in [−1, 1]; result in radians. |
Atan(Float128) |
Float128 |
Computes the arctangent; result in radians. |
Atan2(Float128, Float128) |
Float128 |
Computes atan(y/x) accounting for quadrant; result in radians. |
AsinPi(Float128) |
Float128 |
Computes Asin(value) / π. |
AcosPi(Float128) |
Float128 |
Computes Acos(value) / π. |
AtanPi(Float128) |
Float128 |
Computes Atan(value) / π. |
Atan2Pi(Float128, Float128) |
Float128 |
Computes Atan2(y, x) / π. |
| Method | Returns | Description |
|---|---|---|
Sinh(Float128) |
Float128 |
Computes the hyperbolic sine. |
Cosh(Float128) |
Float128 |
Computes the hyperbolic cosine. |
Tanh(Float128) |
Float128 |
Computes the hyperbolic tangent. |
Asinh(Float128) |
Float128 |
Computes the inverse hyperbolic sine. |
Acosh(Float128) |
Float128 |
Computes the inverse hyperbolic cosine; domain [1, +∞). |
Atanh(Float128) |
Float128 |
Computes the inverse hyperbolic tangent; domain [−1, 1]. |
| Method | Returns | Description |
|---|---|---|
Parse(string, IFormatProvider?) |
Float128 |
Parses a string. |
Parse(string, NumberStyles, IFormatProvider?) |
Float128 |
Parses a string with explicit number styles. |
Parse(ReadOnlySpan<char>, IFormatProvider?) |
Float128 |
Parses a character span. |
Parse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?) |
Float128 |
Parses a character span with explicit number styles. |
TryParse(string?, out Float128) |
bool |
Attempts to parse a string; returns false on failure. |
TryParse(string?, IFormatProvider?, out Float128) |
bool |
Attempts to parse a string with a format provider. |
TryParse(string?, NumberStyles, IFormatProvider?, out Float128) |
bool |
Attempts to parse a string with number styles and a format provider. |
TryParse(ReadOnlySpan<char>, out Float128) |
bool |
Attempts to parse a character span; returns false on failure. |
TryParse(ReadOnlySpan<char>, IFormatProvider?, out Float128) |
bool |
Attempts to parse a character span with a format provider. |
TryParse(ReadOnlySpan<char>, NumberStyles, IFormatProvider?, out Float128) |
bool |
Attempts to parse a character span with number styles and a format provider. |
| Method | Returns | Description |
|---|---|---|
Equals(Float128, Float128) |
bool |
Determines whether two Float128 values are equal under collection-equality semantics. |
public static Float128 Abs(Float128 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 |
Float128 |
The value whose absolute value is to be computed. |
Returns — The absolute value of value.
public static Float128 Negate(Float128 value)Returns the unary negation of value. Equivalent to applying the − unary operator.
| Parameter | Type | Description |
|---|---|---|
value |
Float128 |
The value to negate. |
Returns — The negation of value.
public static int Sign(Float128 value)Returns an integer indicating the sign of the specified value.
| Parameter | Type | Description |
|---|---|---|
value |
Float128 |
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 Float128 Add(Float128 left, Float128 right)Computes the sum of two Float128 values, rounded to nearest, ties-to-even per IEEE 754.
| Parameter | Type | Description |
|---|---|---|
left |
Float128 |
The left addend. |
right |
Float128 |
The right addend. |
Returns — The correctly-rounded sum.
public static Float128 Subtract(Float128 left, Float128 right)Computes the difference of two Float128 values, rounded to nearest, ties-to-even per IEEE 754.
| Parameter | Type | Description |
|---|---|---|
left |
Float128 |
The minuend. |
right |
Float128 |
The subtrahend. |
Returns — The correctly-rounded difference.
public static Float128 Multiply(Float128 left, Float128 right)Computes the product of two Float128 values, rounded to nearest, ties-to-even per IEEE 754. The full 256-bit product of the two 113-bit significands is computed before rounding.
| Parameter | Type | Description |
|---|---|---|
left |
Float128 |
The left multiplicand. |
right |
Float128 |
The right multiplicand. |
Returns — The correctly-rounded product.
public static Float128 Divide(Float128 left, Float128 right)Computes the quotient of two Float128 values, rounded to nearest, ties-to-even per IEEE 754.
| Parameter | Type | Description |
|---|---|---|
left |
Float128 |
The dividend. |
right |
Float128 |
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 Float128 Modulus(Float128 left, Float128 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 |
Float128 |
The dividend. |
right |
Float128 |
The divisor. |
Returns — The truncating remainder.
public static Float128 FusedMultiplyAdd(Float128 left, Float128 right, Float128 addend)Computes (left × right) + addend with a single final rounding, eliminating intermediate rounding error. The product is computed exactly in a 256-bit intermediate and accumulated in a 512-bit buffer before the single round-to-nearest-ties-to-even step.
| Parameter | Type | Description |
|---|---|---|
left |
Float128 |
The first multiplicand. |
right |
Float128 |
The second multiplicand. |
addend |
Float128 |
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 Float128 Ieee754Remainder(Float128 left, Float128 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 |
Float128 |
The dividend. |
right |
Float128 |
The divisor. |
Returns — The IEEE 754 remainder; NaN for invalid combinations (infinity dividend, zero divisor, or any NaN operand).
public static Float128 CopySign(Float128 magnitude, Float128 sign)Returns a Float128 value with the magnitude of magnitude and the sign bit of sign.
| Parameter | Type | Description |
|---|---|---|
magnitude |
Float128 |
The value whose magnitude is used. |
sign |
Float128 |
The value whose sign bit is used. |
Returns — A value combining the magnitude of magnitude with the sign of sign.
public static Float128 Ceiling(Float128 value)Computes the smallest integral Float128 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 Float128 Floor(Float128 value)Computes the largest integral Float128 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 Float128 Truncate(Float128 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 Float128 Round(Float128 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 Float128 Round(Float128 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 |
Float128 |
The value to round. |
digits |
int |
The number of fractional digits. |
Returns — The rounded value.
public static Float128 Round(Float128 value, MidpointRounding mode)Rounds value to the nearest integer using the specified midpoint-rounding strategy.
| Parameter | Type | Description |
|---|---|---|
value |
Float128 |
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 Float128 Round(Float128 value, int digits, MidpointRounding mode)Rounds value to digits fractional digits using the specified midpoint-rounding strategy.
| Parameter | Type | Description |
|---|---|---|
value |
Float128 |
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(Float128 left, Float128 right)Compares two Float128 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 |
Float128 |
The left value. |
right |
Float128 |
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 Float128 Min(Float128 x, Float128 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 Float128 Max(Float128 x, Float128 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 Float128 MinNumber(Float128 x, Float128 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 Float128 MaxNumber(Float128 x, Float128 y)Returns the larger of two values, treating NaN as missing.
public static Float128 MinMagnitude(Float128 x, Float128 y)Returns the value with the smaller absolute magnitude; propagates NaN. When magnitudes are equal, the negative value is preferred.
public static Float128 MaxMagnitude(Float128 x, Float128 y)Returns the value with the larger absolute magnitude; propagates NaN. When magnitudes are equal, the positive value is preferred.
public static Float128 MinMagnitudeNumber(Float128 x, Float128 y)Returns the value with the smaller absolute magnitude; treats NaN as missing.
public static Float128 MaxMagnitudeNumber(Float128 x, Float128 y)Returns the value with the larger absolute magnitude; treats NaN as missing.
public static int ILogB(Float128 value)Returns the integral base-2 logarithm (unbiased binary exponent) of value.
| Parameter | Type | Description |
|---|---|---|
value |
Float128 |
The value to inspect. |
Returns — The unbiased exponent; int.MaxValue for NaN or infinity; int.MinValue for zero.
public static Float128 ScaleB(Float128 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 |
Float128 |
The value to scale. |
n |
int |
The integer power of two. |
Returns — value × 2^n.
public static Float128 BitIncrement(Float128 value)Returns the smallest Float128 value that is greater than value. NaN remains NaN; positive infinity remains positive infinity; negative infinity becomes MinValue; either zero becomes Epsilon.
public static Float128 BitDecrement(Float128 value)Returns the largest Float128 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 Float128 ReciprocalEstimate(Float128 value)Returns the correctly-rounded quotient 1 / value.
public static Float128 ReciprocalSqrtEstimate(Float128 value)Returns an approximation of 1 / √value, faithful to within 1 ULP (inheriting the accuracy of Sqrt).
public static bool IsNaN(Float128 value)Returns true when value is a not-a-number (NaN) value.
public static bool IsInfinity(Float128 value)Returns true when value is positive or negative infinity.
public static bool IsPositiveInfinity(Float128 value)Returns true when value is positive infinity.
public static bool IsNegativeInfinity(Float128 value)Returns true when value is negative infinity.
public static bool IsFinite(Float128 value)Returns true when value is finite (not NaN and not infinity).
public static bool IsNormal(Float128 value)Returns true when value is a normal value — finite, non-zero, and not subnormal.
public static bool IsSubnormal(Float128 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(Float128 value)Returns true when value is positive zero or negative zero.
public static bool IsNegative(Float128 value)Returns true when the sign bit of value is set. This includes negative zero and negative NaN bit patterns.
public static bool IsPositive(Float128 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(Float128 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(Float128 value)Returns true when value is a finite even integer.
public static bool IsOddInteger(Float128 value)Returns true when value is a finite odd integer.
public static bool IsPow2(Float128 value)Returns true when value is a positive integer that is an exact power of two.
public static Float128 Exp(Float128 value)Computes e^value. Returns NaN for NaN; PositiveInfinity for positive infinity or overflow; Zero for negative infinity or underflow.
public static Float128 Exp2(Float128 value)Computes 2^value. For integer arguments that fit in the binary128 exponent range, the result is exact via ScaleB. Returns NaN for NaN; PositiveInfinity on overflow; Zero on underflow.
public static Float128 Exp10(Float128 value)Computes 10^value via Exp(value × ln 10). Returns NaN for NaN; PositiveInfinity on overflow; Zero on underflow.
public static Float128 ExpM1(Float128 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 Float128 Exp2M1(Float128 value)Computes 2^value − 1, accurate near zero. Returns NegativeOne for negative infinity.
public static Float128 Exp10M1(Float128 value)Computes 10^value − 1, accurate near zero. Returns NegativeOne for negative infinity.
public static Float128 Log(Float128 value)Computes the natural logarithm of value. Returns NaN for negative inputs and NaN; NegativeInfinity for zero; PositiveInfinity for positive infinity.
public static Float128 Log2(Float128 value)Computes the base-2 logarithm of value. For exact powers of two, returns the unbiased exponent as a Float128 integer. Returns NaN for negative inputs and NaN; NegativeInfinity for zero.
public static Float128 Log10(Float128 value)Computes the base-10 logarithm of value. Returns NaN for negative inputs and NaN; NegativeInfinity for zero.
public static Float128 Log(Float128 value, Float128 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 |
Float128 |
The value whose logarithm is to be computed. |
newBase |
Float128 |
The logarithm base. |
Returns — log_newBase_(value).
public static Float128 LogP1(Float128 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 Float128 Log2P1(Float128 value)Computes log2(1 + value), accurate near zero.
public static Float128 Log10P1(Float128 value)Computes log10(1 + value), accurate near zero.
public static Float128 Pow(Float128 x, Float128 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 |
Float128 |
The base. |
y |
Float128 |
The exponent. |
Returns — x^y.
public static Float128 Sqrt(Float128 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 binary128 range. Returns NaN for negative inputs or NaN; preserves the sign of zero.
| Parameter | Type | Description |
|---|---|---|
value |
Float128 |
The radicand. |
Returns — √value.
public static Float128 Cbrt(Float128 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 Float128 RootN(Float128 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 |
Float128 |
The radicand. |
n |
int |
The root index. |
Returns — The _n_th root of value.
public static Float128 Hypot(Float128 x, Float128 y)Computes √(x² + y²) (Euclidean length), avoiding intermediate overflow by dividing through by max(|x|, |y|) before squaring.
| Parameter | Type | Description |
|---|---|---|
x |
Float128 |
The first value. |
y |
Float128 |
The second value. |
Returns — √(x² + y²); PositiveInfinity if either argument is infinite.
public static Float128 Sin(Float128 value)Computes the sine of value (angle in radians). Returns NaN for NaN or infinity; preserves the sign of zero.
public static Float128 Cos(Float128 value)Computes the cosine of value (angle in radians). Returns NaN for NaN or infinity; returns One for zero.
public static Float128 Tan(Float128 value)Computes the tangent of value (angle in radians). Returns NaN for NaN or infinity; preserves the sign of zero.
public static (Float128 Sin, Float128 Cos) SinCos(Float128 value)Computes the sine and cosine of value simultaneously, sharing the underlying range-reduction and series evaluations.
| Parameter | Type | Description |
|---|---|---|
value |
Float128 |
The angle, in radians. |
Returns — A tuple (Sin, Cos).
public static Float128 SinPi(Float128 value)Computes sin(π · value). Returns exact zero for integer arguments.
public static Float128 CosPi(Float128 value)Computes cos(π · value). Returns One for zero.
public static Float128 TanPi(Float128 value)Computes tan(π · value). Returns exact zero for integer arguments.
public static (Float128 SinPi, Float128 CosPi) SinCosPi(Float128 value)Computes sin(π · value) and cos(π · value) simultaneously.
Returns — A tuple (SinPi, CosPi).
public static Float128 Asin(Float128 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 Float128 Acos(Float128 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 Float128 Atan(Float128 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 Float128 Atan2(Float128 y, Float128 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 |
Float128 |
The numerator (y-coordinate). |
x |
Float128 |
The denominator (x-coordinate). |
Returns — The angle in radians whose tangent is y/x.
public static Float128 AsinPi(Float128 value)Computes Asin(value) / π.
public static Float128 AcosPi(Float128 value)Computes Acos(value) / π.
public static Float128 AtanPi(Float128 value)Computes Atan(value) / π; returns ±½ for ±infinity.
public static Float128 Atan2Pi(Float128 y, Float128 x)Computes Atan2(y, x) / π, resolving all four quadrants.
public static Float128 Sinh(Float128 value)Computes the hyperbolic sine of value. Preserves the sign of zero; returns ±infinity for ±infinity or on overflow.
public static Float128 Cosh(Float128 value)Computes the hyperbolic cosine of value. Returns One for zero; PositiveInfinity for ±infinity or on overflow.
public static Float128 Tanh(Float128 value)Computes the hyperbolic tangent of value. Saturates to ±1 for large magnitudes and for ±infinity; preserves the sign of zero.
public static Float128 Asinh(Float128 value)Computes the inverse hyperbolic sine of value. Preserves the sign of zero; returns ±infinity for ±infinity.
public static Float128 Acosh(Float128 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 Float128 Atanh(Float128 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 Float128 Parse(string value, IFormatProvider? provider = null)Parses a string representation of a Float128 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 Float128 value.
Exceptions
| Exception | Condition |
|---|---|
FormatException |
value is not in a valid format. |
public static Float128 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 Float128 value.
Exceptions
| Exception | Condition |
|---|---|
FormatException |
value is not in a valid format. |
public static Float128 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 Float128 value.
Exceptions
| Exception | Condition |
|---|---|
FormatException |
The span is not in a valid format. |
public static Float128 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 Float128 value.
Exceptions
| Exception | Condition |
|---|---|
FormatException |
The span is not in a valid format. |
public static bool TryParse(string? value, out Float128 result)Attempts to parse a string into a Float128 value. Returns false without throwing if parsing fails.
| Parameter | Type | Description |
|---|---|---|
value |
string? |
The string to parse. |
result |
out Float128 |
The parsed value on success; otherwise, default. |
Returns — true if parsing succeeded; otherwise, false.
public static bool TryParse(string? value, IFormatProvider? provider, out Float128 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 Float128 |
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 Float128 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 Float128 |
The parsed value on success; otherwise, default. |
Returns — true if parsing succeeded; otherwise, false.
public static bool TryParse(ReadOnlySpan<char> value, out Float128 result)Attempts to parse a character span using the current culture.
| Parameter | Type | Description |
|---|---|---|
value |
ReadOnlySpan<char> |
The character span to parse. |
result |
out Float128 |
The parsed value on success; otherwise, default. |
Returns — true if parsing succeeded; otherwise, false.
public static bool TryParse(ReadOnlySpan<char> value, IFormatProvider? provider, out Float128 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 Float128 |
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 Float128 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 Float128 |
The parsed value on success; otherwise, default. |
Returns — true if parsing succeeded; otherwise, false.
public static bool Equals(Float128 left, Float128 right)Determines whether two Float128 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 |
Float128 |
The first value. |
right |
Float128 |
The second value. |
Returns — true if the values are equal under collection-equality semantics; otherwise, false.
| Method | Returns | Description |
|---|---|---|
CompareTo(Float128) |
int |
Compares this instance with another Float128 using the total order defined by Compare. |
CompareTo(object?) |
int |
Compares this instance with another object. |
Equals(Float128) |
bool |
Determines whether this instance equals another Float128 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 2). |
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 113). |
GetSignificandByteCount() |
int |
Returns the byte count needed to serialise the significand (always 16). |
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(Float128 other)Compares this instance with another Float128 value using the total order defined by Compare: NaN sorts before all numeric values; positive and negative zero compare equal.
| Parameter | Type | Description |
|---|---|---|
other |
Float128 |
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 Float128. |
Returns — A signed ordering indicator.
Exceptions
| Exception | Condition |
|---|---|
ArgumentException |
obj is not null and is not a Float128. |
public bool Equals(Float128 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 Float128 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 2 (sizeof(short)).
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 113.
public int GetSignificandByteCount()Returns the number of bytes required to serialise the significand via TryWriteSignificandBigEndian or TryWriteSignificandLittleEndian.
Returns — Always returns 16.
public bool TryWriteExponentBigEndian(Span<byte> destination, out int bytesWritten)Tries to write the current unbiased exponent as a big-endian signed 16-bit integer to destination.
| Parameter | Type | Description |
|---|---|---|
destination |
Span<byte> |
The target span; must be at least 2 bytes. |
bytesWritten |
out int |
2 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 16-bit integer to destination.
| Parameter | Type | Description |
|---|---|---|
destination |
Span<byte> |
The target span; must be at least 2 bytes. |
bytesWritten |
out int |
2 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 113-bit significand (with the implicit leading bit set for normal values) as a big-endian 16-byte value to destination.
| Parameter | Type | Description |
|---|---|---|
destination |
Span<byte> |
The target span; must be at least 16 bytes. |
bytesWritten |
out int |
16 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 113-bit significand as a little-endian 16-byte value to destination.
| Parameter | Type | Description |
|---|---|---|
destination |
Span<byte> |
The target span; must be at least 16 bytes. |
bytesWritten |
out int |
16 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 binary128 is 36.
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 36 significant digits, for values of any magnitude, including values of 10^36 or more 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.
| 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 +(Float128) |
Float128 |
Unary plus; returns the operand unchanged. |
operator -(Float128) |
Float128 |
Unary negation; flips the sign bit. |
operator ++(Float128) |
Float128 |
Adds one; correctly rounded. |
operator --(Float128) |
Float128 |
Subtracts one; correctly rounded. |
operator +(Float128, Float128) |
Float128 |
IEEE 754 addition. |
operator -(Float128, Float128) |
Float128 |
IEEE 754 subtraction. |
operator *(Float128, Float128) |
Float128 |
IEEE 754 multiplication. |
operator /(Float128, Float128) |
Float128 |
IEEE 754 division. |
operator %(Float128, Float128) |
Float128 |
Truncating remainder (C# % semantics). |
| Operator | Returns | Description |
|---|---|---|
operator &(Float128, Float128) |
Float128 |
Bitwise AND of the raw bit patterns. |
operator |(Float128, Float128) |
Float128 |
Bitwise OR of the raw bit patterns. |
operator ^(Float128, Float128) |
Float128 |
Bitwise XOR of the raw bit patterns. |
operator ~(Float128) |
Float128 |
Bitwise complement of the raw bit pattern. |
| Operator | Returns | Description |
|---|---|---|
operator ==(Float128, Float128) |
bool |
IEEE 754 equality; false if either operand is NaN. |
operator !=(Float128, Float128) |
bool |
IEEE 754 inequality; true if either operand is NaN. |
operator <(Float128, Float128) |
bool |
Less-than; false if either operand is NaN. |
operator <=(Float128, Float128) |
bool |
Less-than-or-equal; false if either operand is NaN. |
operator >(Float128, Float128) |
bool |
Greater-than; false if either operand is NaN. |
operator >=(Float128, Float128) |
bool |
Greater-than-or-equal; false if either operand is NaN. |
| Operator | Description |
|---|---|
implicit operator Float128(sbyte) |
Widens a signed byte; exact. |
implicit operator Float128(byte) |
Widens an unsigned byte; exact. |
implicit operator Float128(short) |
Widens a 16-bit signed integer; exact. |
implicit operator Float128(ushort) |
Widens a 16-bit unsigned integer; exact. |
implicit operator Float128(int) |
Widens a 32-bit signed integer; exact. |
implicit operator Float128(uint) |
Widens a 32-bit unsigned integer; exact. |
implicit operator Float128(long) |
Widens a 64-bit signed integer; exact. |
implicit operator Float128(ulong) |
Widens a 64-bit unsigned integer; exact. |
implicit operator Float128(Int128) |
Widens a 128-bit signed integer; rounded for values exceeding 113 significant bits. |
implicit operator Float128(UInt128) |
Widens a 128-bit unsigned integer; rounded for values exceeding 113 significant bits. |
implicit operator Float128(char) |
Widens a char code-point; exact. |
implicit operator Float128(Half) |
Widens a Half; exact (11-bit significand fits in 113 bits). |
implicit operator Float128(float) |
Widens a float; exact (24-bit significand fits in 113 bits), preserving NaN payloads, infinities and subnormals. |
implicit operator Float128(double) |
Widens a double; exact (53-bit significand fits in 113 bits), preserving NaN payloads, infinities and subnormals. |
implicit operator Float128(decimal) |
Converts a decimal; exact (96-bit significand fits in 113 bits). |
| Operator | Description |
|---|---|
explicit operator sbyte(Float128) |
Truncates toward zero; saturates on overflow; returns 0 for NaN. |
explicit operator checked sbyte(Float128) |
Throws OverflowException for NaN, infinity, or out-of-range. |
explicit operator byte(Float128) |
Truncates toward zero; saturates on overflow; returns 0 for NaN. |
explicit operator checked byte(Float128) |
Throws OverflowException for NaN, infinity, negative, or out-of-range. |
explicit operator short(Float128) |
Truncates toward zero; saturates on overflow; returns 0 for NaN. |
explicit operator checked short(Float128) |
Throws OverflowException for NaN, infinity, or out-of-range. |
explicit operator ushort(Float128) |
Truncates toward zero; saturates on overflow; returns 0 for NaN. |
explicit operator checked ushort(Float128) |
Throws OverflowException for NaN, infinity, negative, or out-of-range. |
explicit operator int(Float128) |
Truncates toward zero; saturates on overflow; returns 0 for NaN. |
explicit operator checked int(Float128) |
Throws OverflowException for NaN, infinity, or out-of-range. |
explicit operator uint(Float128) |
Truncates toward zero; saturates on overflow; returns 0 for NaN. |
explicit operator checked uint(Float128) |
Throws OverflowException for NaN, infinity, negative, or out-of-range. |
explicit operator long(Float128) |
Truncates toward zero; saturates on overflow; returns 0 for NaN. |
explicit operator checked long(Float128) |
Throws OverflowException for NaN, infinity, or out-of-range. |
explicit operator ulong(Float128) |
Truncates toward zero; saturates on overflow; returns 0 for NaN. |
explicit operator checked ulong(Float128) |
Throws OverflowException for NaN, infinity, negative, or out-of-range. |
explicit operator Int128(Float128) |
Truncates toward zero; saturates on overflow; returns Int128.Zero for NaN. |
explicit operator checked Int128(Float128) |
Throws OverflowException for NaN, infinity, or out-of-range. |
explicit operator UInt128(Float128) |
Truncates toward zero; saturates on overflow; returns UInt128.Zero for NaN or negative. |
explicit operator checked UInt128(Float128) |
Throws OverflowException for NaN, infinity, negative, or out-of-range. |
explicit operator char(Float128) |
Truncates toward zero; saturates on overflow; returns (char)0 for NaN. |
explicit operator checked char(Float128) |
Throws OverflowException for NaN, infinity, negative, or out-of-range. |
explicit operator BigInteger(Float128) |
Truncates toward zero; exact for any finite integer. |
explicit operator Half(Float128) |
Converts to the nearest Half (via double); may lose precision. |
explicit operator float(Float128) |
Converts to the nearest float (via double); may lose precision. |
explicit operator double(Float128) |
Converts to the nearest double; rounds to nearest, ties-to-even. |
explicit operator decimal(Float128) |
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)(Float128)0.1m is 0.1m). Throws OverflowException for NaN, infinity, or once the magnitude rounds to 2^96. |
explicit operator BigDecimal(Float128) |
Converts to an exact BigDecimal; throws OverflowException for NaN or infinity. |
explicit operator Float128(BigDecimal) |
Converts a BigDecimal to the nearest Float128; saturates to ±infinity on overflow. |
explicit operator Float128(BigInteger) |
Converts a BigInteger to the nearest Float128; saturates to ±infinity on overflow. |
public static Float128 operator +(Float128 value)Returns value unchanged (identity operation).
public static Float128 operator -(Float128 value)Returns the negation of value by flipping the sign bit. Applies to all values including NaN and zero.
public static Float128 operator ++(Float128 value)Returns value + 1, correctly rounded to nearest, ties-to-even.
public static Float128 operator --(Float128 value)Returns value - 1, correctly rounded to nearest, ties-to-even.
public static Float128 operator +(Float128 left, Float128 right)Computes the IEEE 754 sum of left and right.
public static Float128 operator -(Float128 left, Float128 right)Computes the IEEE 754 difference of left and right.
public static Float128 operator *(Float128 left, Float128 right)Computes the IEEE 754 product of left and right.
public static Float128 operator /(Float128 left, Float128 right)Computes the IEEE 754 quotient of left and right.
public static Float128 operator %(Float128 left, Float128 right)Computes the truncating remainder of left divided by right (C# % semantics; the result has the same sign as left).
public static Float128 operator &(Float128 left, Float128 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 Float128 operator |(Float128 left, Float128 right)Returns the bitwise OR of the raw bit patterns of left and right.
public static Float128 operator ^(Float128 left, Float128 right)Returns the bitwise XOR of the raw bit patterns of left and right.
public static Float128 operator ~(Float128 value)Returns the bitwise complement of the raw bit pattern of value. The result is AllBitsSet when value is Zero.
public static bool operator ==(Float128 left, Float128 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 !=(Float128 left, Float128 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 <(Float128 left, Float128 right)Returns true when left is strictly less than right. Returns false if either operand is NaN.
public static bool operator <=(Float128 left, Float128 right)Returns true when left is less than or equal to right. Returns false if either operand is NaN.
public static bool operator >(Float128 left, Float128 right)Returns true when left is strictly greater than right. Returns false if either operand is NaN.
public static bool operator >=(Float128 left, Float128 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