Skip to content

Latest commit

 

History

History
769 lines (428 loc) · 75.2 KB

File metadata and controls

769 lines (428 loc) · 75.2 KB

System.FloatingPoint

The library provides the floating-point numeric types Quarter, Half and BFloat16.

All types provided by this library are not hardware-accelerated and are implemented programmatically, so their performance is significantly lower than that of the native float and double types.

API reference

namespace System

  • struct Quarter

    • field static Epsilon -> Quarter static readonly Represents the smallest positive System.Quarter value greater than zero.
    • field static MaxValue -> Quarter static readonly Represents the largest possible value of System.Quarter.
    • field static MinValue -> Quarter static readonly Represents the smallest possible value of System.Quarter.
    • field static NaN -> Quarter static readonly Represents not a number (NaN).
    • field static NegativeInfinity -> Quarter static readonly Represents negative infinity.
    • field static PositiveInfinity -> Quarter static readonly Represents positive infinity.
    • constructor Quarter(float value) -> new Quarter Initializes a new instance of System.Quarter to the value of the specified single-precision floating-point number.
    • constructor Quarter(int value) -> new Quarter Initializes a new instance of System.Quarter to the value of the specified 32-bit signed integer.
    • constructor Quarter(long value) -> new Quarter Initializes a new instance of System.Quarter to the value of the specified 64-bit signed integer.
    • constructor Quarter(double value) -> new Quarter Initializes a new instance of System.Quarter to the value of the specified double-precision floating-point number.
    • constructor Quarter(decimal value) -> new Quarter Initializes a new instance of System.Quarter to the value of the specified decimal number.
    • constructor Quarter(uint value) -> new Quarter Initializes a new instance of System.Quarter to the value of the specified 32-bit unsigned integer.
    • constructor Quarter(ulong value) -> new Quarter Initializes a new instance of System.Quarter to the value of the specified 64-bit unsigned integer.
    • method static Negate(Quarter quarter) -> Quarter static Returns the result of multiplying the specified System.Quarter value by negative one.
    • method static Add(Quarter quarter1, Quarter quarter2) -> Quarter static Adds two specified System.Quarter values.
    • method static Substract(Quarter quarter1, Quarter quarter2) -> Quarter static Subtracts one specified System.Quarter value from another.
    • method static Multiply(Quarter quarter1, Quarter quarter2) -> Quarter static Multiplies two specified System.Quarter values.
    • method static Divide(Quarter quarter1, Quarter quarter2) -> Quarter static Divides two specified System.Quarter values.
    • operator +(Quarter quarter) -> Quarter Returns the value of the System.Quarter operand (the sign of the operand is unchanged).
    • operator -(Quarter quarter) -> Quarter Negates the value of the specified System.Quarter operand.
    • operator ++(Quarter quarter) -> Quarter Increments the System.Quarter operand by 1.
    • operator --(Quarter quarter) -> Quarter Decrements the System.Quarter operand by one.
    • operator +(Quarter quarter1, Quarter quarter2) -> Quarter Adds two specified System.Quarter values.
    • operator -(Quarter quarter1, Quarter quarter2) -> Quarter Subtracts two specified System.Quarter values.
    • operator *(Quarter quarter1, Quarter quarter2) -> Quarter Multiplies two specified System.Quarter values.
    • operator /(Quarter quarter1, Quarter quarter2) -> Quarter Divides two specified System.Quarter values.
    • operator ==(Quarter quarter1, Quarter quarter2) -> bool Returns a value indicating whether two instances of System.Quarter are equal.
    • operator !=(Quarter quarter1, Quarter quarter2) -> bool Returns a value indicating whether two instances of System.Quarter are not equal.
    • operator <(Quarter quarter1, Quarter quarter2) -> bool Returns a value indicating whether a specified System.Quarter is less than another specified System.Quarter.
    • operator >(Quarter quarter1, Quarter quarter2) -> bool Returns a value indicating whether a specified System.Quarter is greater than another specified System.Quarter.
    • operator <=(Quarter quarter1, Quarter quarter2) -> bool Returns a value indicating whether a specified System.Quarter is less than or equal to another specified System.Quarter.
    • operator >=(Quarter quarter1, Quarter quarter2) -> bool Returns a value indicating whether a specified System.Quarter is greater than or equal to another specified System.Quarter.
    • operator implicit(byte value) -> Quarter Converts an 8-bit unsigned integer to a System.Quarter.
    • operator implicit(short value) -> Quarter Converts a 16-bit signed integer to a System.Quarter.
    • operator implicit(char value) -> Quarter Converts a Unicode character to a System.Quarter.
    • operator implicit(int value) -> Quarter Converts a 32-bit signed integer to a System.Quarter.
    • operator implicit(long value) -> Quarter Converts a 64-bit signed integer to a System.Quarter.
    • operator explicit(Half value) -> Quarter Converts a half-precision floating-point number to a System.Quarter.
    • operator explicit(BFloat16 value) -> Quarter Converts a 16-bit google brain floating-point number to a System.Quarter.
    • operator explicit(float value) -> Quarter Converts a single-precision floating-point number to a System.Quarter.
    • operator explicit(double value) -> Quarter Converts a double-precision floating-point number to a System.Quarter.
    • operator explicit(decimal value) -> Quarter Converts a decimal number to a System.Quarter.
    • operator explicit(Quarter value) -> byte Converts a System.Quarter to an 8-bit unsigned integer.
    • operator explicit(Quarter value) -> char Converts a System.Quarter to a Unicode character.
    • operator explicit(Quarter value) -> short Converts a System.Quarter to a 16-bit signed integer.
    • operator explicit(Quarter value) -> int Converts a System.Quarter to a 32-bit signed integer.
    • operator explicit(Quarter value) -> long Converts a System.Quarter to a 64-bit signed integer.
    • operator implicit(Quarter value) -> float Converts a System.Quarter to a single-precision floating-point number.
    • operator implicit(Quarter value) -> double Converts a System.Quarter to a double-precision floating-point number.
    • operator explicit(Quarter value) -> decimal Converts a System.Quarter to a decimal number.
    • operator implicit(sbyte value) -> Quarter Converts an 8-bit signed integer to a System.Quarter.
    • operator implicit(ushort value) -> Quarter Converts a 16-bit unsigned integer to a System.Quarter.
    • operator implicit(uint value) -> Quarter Converts a 32-bit unsigned integer to a System.Quarter.
    • operator implicit(ulong value) -> Quarter Converts a 64-bit unsigned integer to a System.Quarter.
    • operator explicit(Quarter value) -> sbyte Converts a System.Quarter to an 8-bit signed integer.
    • operator explicit(Quarter value) -> ushort Converts a System.Quarter to a 16-bit unsigned integer.
    • operator explicit(Quarter value) -> uint Converts a System.Quarter to a 32-bit unsigned integer.
    • operator explicit(Quarter value) -> ulong Converts a System.Quarter to a 64-bit unsigned integer.
    • method CompareTo(Quarter other) -> int Compares this instance to a specified System.Quarter object.
    • method CompareTo(object obj) -> int Compares this instance to a specified System.Object.
    • method Equals(Quarter other) -> bool Returns a value indicating whether this instance and a specified System.Quarter object represent the same value.
    • method Equals(object obj) -> bool override Returns a value indicating whether this instance and a specified System.Object represent the same type and value.
    • method GetHashCode() -> int override Returns the hash code for this instance.
    • method GetTypeCode() -> TypeCode Returns the System.TypeCode for value type System.Quarter.
    • method static GetBytes(Quarter value) -> byte[] static Returns the specified quarter-precision floating point value as an array of bytes.
    • method static GetBits(Quarter value) -> byte static Converts the value of a specified instance of System.Quarter to its equivalent binary representation.
    • method static ToQuarter(byte[] value, int startIndex) -> Quarter static Returns a quarter-precision floating point number converted from one byte at a specified position in a byte array.
    • method static ToQuarter(byte bits) -> Quarter static Returns a quarter-precision floating point number converted from its binary representation.
    • method static Sign(Quarter value) -> int static Returns a value indicating the sign of a quarter-precision floating-point number.
    • method static Abs(Quarter value) -> Quarter static Returns the absolute value of a quarter-precision floating-point number.
    • method static Max(Quarter value1, Quarter value2) -> Quarter static Returns the larger of two quarter-precision floating-point numbers.
    • method static Min(Quarter value1, Quarter value2) -> Quarter static Returns the smaller of two quarter-precision floating-point numbers.
    • method static IsNaN(Quarter quarter) -> bool static Returns a value indicating whether the specified number evaluates to not a number (System.Quarter.NaN).
    • method static IsInfinity(Quarter quarter) -> bool static Returns a value indicating whether the specified number evaluates to negative or positive infinity.
    • method static IsNegativeInfinity(Quarter quarter) -> bool static Returns a value indicating whether the specified number evaluates to negative infinity.
    • method static IsPositiveInfinity(Quarter quarter) -> boo static Returns a value indicating whether the specified number evaluates to positive infinity.
    • method static Parse(string value) -> Quarter static Converts the string representation of a number to its System.Quarter equivalent.
    • method static Parse(string value, IFormatProvider provider) -> Quarter static Converts the string representation of a number to its System.Quarter equivalent using the specified culture-specific format information.
    • method static Parse(string value, NumberStyles style) -> Quarter static Converts the string representation of a number in a specified style to its System.Quarter equivalent.
    • method static Parse(string value, NumberStyles style, IFormatProvider provider) -> Quarter static Converts the string representation of a number to its System.Quarter equivalent using the specified style and culture-specific format.
    • method static TryParse(string value, out Quarter result) -> bool static Converts the string representation of a number to its System.Quarter equivalent. A return value indicates whether the conversion succeeded or failed.
    • method static TryParse(string value, NumberStyles style, IFormatProvider provider, out Quarter result) -> bool static Converts the string representation of a number to its System.Quarter equivalent using the specified style and culture-specific format. A return value indicates whether the conversion succeeded or failed.
    • method ToString() -> string override Converts the numeric value of this instance to its equivalent string representation.
    • method ToString(IFormatProvider formatProvider) -> string override Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information.
    • method ToString(string format) -> string override Converts the numeric value of this instance to its equivalent string representation, using the specified format.
    • method ToString(string format, IFormatProvider formatProvider) -> string override Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific format information.
    • method IConvertible.ToSingle(IFormatProvider provider) -> float
    • method IConvertible.GetTypeCode() -> TypeCode
    • method IConvertible.ToBoolean(IFormatProvider provider) -> bool
    • method IConvertible.ToByte(IFormatProvider provider) -> byte
    • method IConvertible.ToChar(IFormatProvider provider) -> char
    • method IConvertible.ToDateTime(IFormatProvider provider) -> DateTime
    • method IConvertible.ToDecimal(IFormatProvider provider) -> decimal
    • method IConvertible.ToDouble(IFormatProvider provider) -> double
    • method IConvertible.ToInt16(IFormatProvider provider) -> short
    • method IConvertible.ToInt32(IFormatProvider provider) -> int
    • method IConvertible.ToInt64(IFormatProvider provider) -> long
    • method IConvertible.ToSByte(IFormatProvider provider) -> sbyte
    • method IConvertible.ToString(IFormatProvider provider) -> string
    • method IConvertible.ToType(Type conversionType, IFormatProvider provider) -> Type
    • method IConvertible.ToUInt16(IFormatProvider provider) -> ushort
    • method IConvertible.ToUInt32(IFormatProvider provider) -> uint
    • method IConvertible.ToUInt64(IFormatProvider provider) -> ulong
  • struct Half

    • field static Epsilon -> Half static readonly Represents the smallest positive System.Half value greater than zero.
    • field static MaxValue -> Half static readonly Represents the largest possible value of System.Half.
    • field static MinValue -> Half static readonly Represents the smallest possible value of System.Half.
    • field static NaN -> Half static readonly Represents not a number (NaN).
    • field static NegativeInfinity -> Half static readonly Represents negative infinity.
    • field static PositiveInfinity -> Half static readonly Represents positive infinity.
    • constructor Half(float value) -> new Half Initializes a new instance of System.Half to the value of the specified single-precision floating-point number.
    • constructor Half(int value) -> new Half Initializes a new instance of System.Half to the value of the specified 32-bit signed integer.
    • constructor Half(long value) -> new Half Initializes a new instance of System.Half to the value of the specified 64-bit signed integer.
    • constructor Half(double value) -> new Half Initializes a new instance of System.Half to the value of the specified double-precision floating-point number.
    • constructor Half(decimal value) -> new Half Initializes a new instance of System.Half to the value of the specified decimal number.
    • constructor Half(uint value) -> new Half Initializes a new instance of System.Half to the value of the specified 32-bit unsigned integer.
    • constructor Half(ulong value) -> new Half Initializes a new instance of System.Half to the value of the specified 64-bit unsigned integer.
    • method static Negate(Half half) -> Half static Returns the result of multiplying the specified System.Half value by negative one.
    • method static Add(Half half1, Half half2) -> Half static Adds two specified System.Half values.
    • method static Substract(Half half1, Half half2) -> Half static Subtracts one specified System.Half value from another.
    • method static Multiply(Half half1, Half half2) -> Half static Multiplies two specified System.Half values.
    • method static Divide(Half half1, Half half2) -> Half static Divides two specified System.Half values.
    • operator +(Half half) -> Half Returns the value of the System.Half operand (the sign of the operand is unchanged).
    • operator -(Half half) -> Half Negates the value of the specified System.Half operand.
    • operator ++(Half half) -> Half Increments the System.Half operand by 1.
    • operator --(Half half) -> Half Decrements the System.Half operand by one.
    • operator +(Half half1, Half half2) -> Half Adds two specified System.Half values.
    • operator -(Half half1, Half half2) -> Half Subtracts two specified System.Half values.
    • operator *(Half half1, Half half2) -> Half Multiplies two specified System.Half values.
    • operator /(Half half1, Half half2) -> Half Divides two specified System.Half values.
    • operator ==(Half half1, Half half2) -> bool Returns a value indicating whether two instances of System.Half are equal.
    • operator !=(Half half1, Half half2) -> bool Returns a value indicating whether two instances of System.Half are not equal.
    • operator <(Half half1, Half half2) -> bool Returns a value indicating whether a specified System.Half is less than another specified System.Half.
    • operator >(Half half1, Half half2) -> bool Returns a value indicating whether a specified System.Half is greater than another specified System.Half.
    • operator <=(Half half1, Half half2) -> bool Returns a value indicating whether a specified System.Half is less than or equal to another specified System.Half.
    • operator >=(Half half1, Half half2) -> bool Returns a value indicating whether a specified System.Half is greater than or equal to another specified System.Half.
    • operator implicit(byte value) -> Half Converts an 8-bit unsigned integer to a System.Half.
    • operator implicit(short value) -> Half Converts a 16-bit signed integer to a System.Half.
    • operator implicit(char value) -> Half Converts a Unicode character to a System.Half.
    • operator implicit(int value) -> Half Converts a 32-bit signed integer to a System.Half.
    • operator implicit(long value) -> Half Converts a 64-bit signed integer to a System.Half.
    • operator implicit(Quarter value) -> Half Converts a quarter-precision floating-point number to a System.Half.
    • operator explicit(BFloat16 value) -> Half Converts a 16-bit google brain floating-point number to a System.Half.
    • operator explicit(float value) -> Half Converts a single-precision floating-point number to a System.Half.
    • operator explicit(double value) -> Half Converts a double-precision floating-point number to a System.Half.
    • operator explicit(decimal value) -> Half Converts a decimal number to a System.Half.
    • operator explicit(Half value) -> byte Converts a System.Half to an 8-bit unsigned integer.
    • operator explicit(Half value) -> char Converts a System.Half to a Unicode character.
    • operator explicit(Half value) -> short Converts a System.Half to a 16-bit signed integer.
    • operator explicit(Half value) -> int Converts a System.Half to a 32-bit signed integer.
    • operator explicit(Half value) -> long Converts a System.Half to a 64-bit signed integer.
    • operator implicit(Half value) -> float Converts a System.Half to a single-precision floating-point number.
    • operator implicit(Half value) -> double Converts a System.Half to a double-precision floating-point number.
    • operator explicit(Half value) -> decimal Converts a System.Half to a decimal number.
    • operator implicit(sbyte value) -> Half Converts an 8-bit signed integer to a System.Half.
    • operator implicit(ushort value) -> Half Converts a 16-bit unsigned integer to a System.Half.
    • operator implicit(uint value) -> Half Converts a 32-bit unsigned integer to a System.Half.
    • operator implicit(ulong value) -> Half Converts a 64-bit unsigned integer to a System.Half.
    • operator explicit(Half value) -> sbyte Converts a System.Half to an 8-bit signed integer.
    • operator explicit(Half value) -> ushort Converts a System.Half to a 16-bit unsigned integer.
    • operator explicit(Half value) -> uint Converts a System.Half to a 32-bit unsigned integer.
    • operator explicit(Half value) -> ulong Converts a System.Half to a 64-bit unsigned integer.
    • method CompareTo(Half other) -> int Compares this instance to a specified System.Half object.
    • method CompareTo(object obj) -> int Compares this instance to a specified System.Object.
    • method Equals(Half other) -> bool Returns a value indicating whether this instance and a specified System.Half object represent the same value.
    • method Equals(object obj) -> bool override Returns a value indicating whether this instance and a specified System.Object represent the same type and value.
    • method GetHashCode() -> int override Returns the hash code for this instance.
    • method GetTypeCode() -> TypeCode Returns the System.TypeCode for value type System.Half.
    • method static GetBytes(Half value) -> byte[] static Returns the specified half-precision floating point value as an array of bytes.
    • method static GetBits(Half value) -> ushort static Converts the value of a specified instance of System.Half to its equivalent binary representation.
    • method static ToHalf(byte[] value, int startIndex) -> Half static Returns a half-precision floating point number converted from two bytes at a specified position in a byte array.
    • method static ToHalf(ushort bits) -> Half static Returns a half-precision floating point number converted from its binary representation.
    • method static Sign(Half value) -> int static Returns a value indicating the sign of a half-precision floating-point number.
    • method static Abs(Half value) -> Half static Returns the absolute value of a half-precision floating-point number.
    • method static Max(Half value1, Half value2) -> Half static Returns the larger of two half-precision floating-point numbers.
    • method static Min(Half value1, Half value2) -> Half static Returns the smaller of two half-precision floating-point numbers.
    • method static IsNaN(Half half) -> bool static Returns a value indicating whether the specified number evaluates to not a number (System.Half.NaN).
    • method static IsInfinity(Half half) -> bool static Returns a value indicating whether the specified number evaluates to negative or positive infinity.
    • method static IsNegativeInfinity(Half half) -> bool static Returns a value indicating whether the specified number evaluates to negative infinity.
    • method static IsPositiveInfinity(Half half) -> boo static Returns a value indicating whether the specified number evaluates to positive infinity.
    • method static Parse(string value) -> Half static Converts the string representation of a number to its System.Half equivalent.
    • method static Parse(string value, IFormatProvider provider) -> Half static Converts the string representation of a number to its System.Half equivalent using the specified culture-specific format information.
    • method static Parse(string value, NumberStyles style) -> Half static Converts the string representation of a number in a specified style to its System.Half equivalent.
    • method static Parse(string value, NumberStyles style, IFormatProvider provider) -> Half static Converts the string representation of a number to its System.Half equivalent using the specified style and culture-specific format.
    • method static TryParse(string value, out Half result) -> bool static Converts the string representation of a number to its System.Half equivalent. A return value indicates whether the conversion succeeded or failed.
    • method static TryParse(string value, NumberStyles style, IFormatProvider provider, out Half result) -> bool static Converts the string representation of a number to its System.Half equivalent using the specified style and culture-specific format. A return value indicates whether the conversion succeeded or failed.
    • method ToString() -> string override Converts the numeric value of this instance to its equivalent string representation.
    • method ToString(IFormatProvider formatProvider) -> string override Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information.
    • method ToString(string format) -> string override Converts the numeric value of this instance to its equivalent string representation, using the specified format.
    • method ToString(string format, IFormatProvider formatProvider) -> string override Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific format information.
    • method IConvertible.ToSingle(IFormatProvider provider) -> float
    • method IConvertible.GetTypeCode() -> TypeCode
    • method IConvertible.ToBoolean(IFormatProvider provider) -> bool
    • method IConvertible.ToByte(IFormatProvider provider) -> byte
    • method IConvertible.ToChar(IFormatProvider provider) -> char
    • method IConvertible.ToDateTime(IFormatProvider provider) -> DateTime
    • method IConvertible.ToDecimal(IFormatProvider provider) -> decimal
    • method IConvertible.ToDouble(IFormatProvider provider) -> double
    • method IConvertible.ToInt16(IFormatProvider provider) -> short
    • method IConvertible.ToInt32(IFormatProvider provider) -> int
    • method IConvertible.ToInt64(IFormatProvider provider) -> long
    • method IConvertible.ToSByte(IFormatProvider provider) -> sbyte
    • method IConvertible.ToString(IFormatProvider provider) -> string
    • method IConvertible.ToType(Type conversionType, IFormatProvider provider) -> Type
    • method IConvertible.ToUInt16(IFormatProvider provider) -> ushort
    • method IConvertible.ToUInt32(IFormatProvider provider) -> uint
    • method IConvertible.ToUInt64(IFormatProvider provider) -> ulong
  • struct BFloat16

    • field static Epsilon -> BFloat16 static readonly Represents the smallest positive System.BFloat16 value greater than zero.
    • field static MaxValue -> BFloat16 static readonly Represents the largest possible value of System.BFloat16.
    • field static MinValue -> BFloat16 static readonly Represents the smallest possible value of System.BFloat16.
    • field static NaN -> BFloat16 static readonly Represents not a number (NaN).
    • field static NegativeInfinity -> BFloat16 static readonly Represents negative infinity.
    • field static PositiveInfinity -> BFloat16 static readonly Represents positive infinity.
    • constructor BFloat16(float value) -> new BFloat16 Initializes a new instance of System.BFloat16 to the value of the specified single-precision floating-point number.
    • constructor BFloat16(int value) -> new BFloat16 Initializes a new instance of System.BFloat16 to the value of the specified 32-bit signed integer.
    • constructor BFloat16(long value) -> new BFloat16 Initializes a new instance of System.BFloat16 to the value of the specified 64-bit signed integer.
    • constructor BFloat16(double value) -> new BFloat16 Initializes a new instance of System.BFloat16 to the value of the specified double-precision floating-point number.
    • constructor BFloat16(decimal value) -> new BFloat16 Initializes a new instance of System.BFloat16 to the value of the specified decimal number.
    • constructor BFloat16(uint value) -> new BFloat16 Initializes a new instance of System.BFloat16 to the value of the specified 32-bit unsigned integer.
    • constructor BFloat16(ulong value) -> new BFloat16 Initializes a new instance of System.BFloat16 to the value of the specified 64-bit unsigned integer.
    • method static Negate(BFloat16 bfloat16) -> BFloat16 static Returns the result of multiplying the specified System.BFloat16 value by negative one.
    • method static Add(BFloat16 bfloat161, BFloat16 bfloat162) -> BFloat16 static Adds two specified System.BFloat16 values.
    • method static Substract(BFloat16 bfloat161, BFloat16 bfloat162) -> BFloat16 static Subtracts one specified System.BFloat16 value from another.
    • method static Multiply(BFloat16 bfloat161, BFloat16 bfloat162) -> BFloat16 static Multiplies two specified System.BFloat16 values.
    • method static Divide(BFloat16 bfloat161, BFloat16 bfloat162) -> BFloat16 static Divides two specified System.BFloat16 values.
    • operator +(BFloat16 bfloat16) -> BFloat16 Returns the value of the System.BFloat16 operand (the sign of the operand is unchanged).
    • operator -(BFloat16 bfloat16) -> BFloat16 Negates the value of the specified System.BFloat16 operand.
    • operator ++(BFloat16 bfloat16) -> BFloat16 Increments the System.BFloat16 operand by 1.
    • operator --(BFloat16 bfloat16) -> BFloat16 Decrements the System.BFloat16 operand by one.
    • operator +(BFloat16 bfloat161, BFloat16 bfloat162) -> BFloat16 Adds two specified System.BFloat16 values.
    • operator -(BFloat16 bfloat161, BFloat16 bfloat162) -> BFloat16 Subtracts two specified System.BFloat16 values.
    • operator *(BFloat16 bfloat161, BFloat16 bfloat162) -> BFloat16 Multiplies two specified System.BFloat16 values.
    • operator /(BFloat16 bfloat161, BFloat16 bfloat162) -> BFloat16 Divides two specified System.BFloat16 values.
    • operator ==(BFloat16 bfloat161, BFloat16 bfloat162) -> bool Returns a value indicating whether two instances of System.BFloat16 are equal.
    • operator !=(BFloat16 bfloat161, BFloat16 bfloat162) -> bool Returns a value indicating whether two instances of System.BFloat16 are not equal.
    • operator <(BFloat16 bfloat161, BFloat16 bfloat162) -> bool Returns a value indicating whether a specified System.BFloat16 is less than another specified System.BFloat16.
    • operator >(BFloat16 bfloat161, BFloat16 bfloat162) -> bool Returns a value indicating whether a specified System.BFloat16 is greater than another specified System.BFloat16.
    • operator <=(BFloat16 bfloat161, BFloat16 bfloat162) -> bool Returns a value indicating whether a specified System.BFloat16 is less than or equal to another specified System.BFloat16.
    • operator >=(BFloat16 bfloat161, BFloat16 bfloat162) -> bool Returns a value indicating whether a specified System.BFloat16 is greater than or equal to another specified System.BFloat16.
    • operator implicit(byte value) -> BFloat16 Converts an 8-bit unsigned integer to a System.BFloat16.
    • operator implicit(short value) -> BFloat16 Converts a 16-bit signed integer to a System.BFloat16.
    • operator implicit(char value) -> BFloat16 Converts a Unicode character to a System.BFloat16.
    • operator implicit(int value) -> BFloat16 Converts a 32-bit signed integer to a System.BFloat16.
    • operator implicit(long value) -> BFloat16 Converts a 64-bit signed integer to a System.BFloat16.
    • operator implicit(Quarter value) -> BFloat16 Converts a quarter-precision floating-point number to a System.BFloat16.
    • operator implicit(Half value) -> BFloat16 Converts a half-precision floating-point number to a System.BFloat16.
    • operator explicit(float value) -> BFloat16 Converts a single-precision floating-point number to a System.BFloat16.
    • operator explicit(double value) -> BFloat16 Converts a double-precision floating-point number to a System.BFloat16.
    • operator explicit(decimal value) -> BFloat16 Converts a decimal number to a System.BFloat16.
    • operator explicit(BFloat16 value) -> byte Converts a System.BFloat16 to an 8-bit unsigned integer.
    • operator explicit(BFloat16 value) -> char Converts a System.BFloat16 to a Unicode character.
    • operator explicit(BFloat16 value) -> short Converts a System.BFloat16 to a 16-bit signed integer.
    • operator explicit(BFloat16 value) -> int Converts a System.BFloat16 to a 32-bit signed integer.
    • operator explicit(BFloat16 value) -> long Converts a System.BFloat16 to a 64-bit signed integer.
    • operator implicit(BFloat16 value) -> float Converts a System.BFloat16 to a single-precision floating-point number.
    • operator implicit(BFloat16 value) -> double Converts a System.BFloat16 to a double-precision floating-point number.
    • operator explicit(BFloat16 value) -> decimal Converts a System.BFloat16 to a decimal number.
    • operator implicit(sbyte value) -> BFloat16 Converts an 8-bit signed integer to a System.BFloat16.
    • operator implicit(ushort value) -> BFloat16 Converts a 16-bit unsigned integer to a System.BFloat16.
    • operator implicit(uint value) -> BFloat16 Converts a 32-bit unsigned integer to a System.BFloat16.
    • operator implicit(ulong value) -> BFloat16 Converts a 64-bit unsigned integer to a System.BFloat16.
    • operator explicit(BFloat16 value) -> sbyte Converts a System.BFloat16 to an 8-bit signed integer.
    • operator explicit(BFloat16 value) -> ushort Converts a System.BFloat16 to a 16-bit unsigned integer.
    • operator explicit(BFloat16 value) -> uint Converts a System.BFloat16 to a 32-bit unsigned integer.
    • operator explicit(BFloat16 value) -> ulong Converts a System.BFloat16 to a 64-bit unsigned integer.
    • method CompareTo(BFloat16 other) -> int Compares this instance to a specified System.BFloat16 object.
    • method CompareTo(object obj) -> int Compares this instance to a specified System.Object.
    • method Equals(BFloat16 other) -> bool Returns a value indicating whether this instance and a specified System.BFloat16 object represent the same value.
    • method Equals(object obj) -> bool override Returns a value indicating whether this instance and a specified System.Object represent the same type and value.
    • method GetHashCode() -> int override Returns the hash code for this instance.
    • method GetTypeCode() -> TypeCode Returns the System.TypeCode for value type System.BFloat16.
    • method static GetBytes(BFloat16 value) -> byte[] static Returns the specified 16-bit google brain floating point value as an array of bytes.
    • method static GetBits(BFloat16 value) -> byte static Converts the value of a specified instance of System.BFloat16 to its equivalent binary representation.
    • method static ToBFloat16(byte[] value, int startIndex) -> BFloat16 static Returns a 16-bit google brain floating point number converted from one byte at a specified position in a byte array.
    • method static ToBFloat16(byte bits) -> BFloat16 static Returns a 16-bit google brain floating point number converted from its binary representation.
    • method static Sign(BFloat16 value) -> int static Returns a value indicating the sign of a 16-bit google brain floating-point number.
    • method static Abs(BFloat16 value) -> BFloat16 static Returns the absolute value of a 16-bit google brain floating-point number.
    • method static Max(BFloat16 value1, BFloat16 value2) -> BFloat16 static Returns the larger of two 16-bit google brain floating-point numbers.
    • method static Min(BFloat16 value1, BFloat16 value2) -> BFloat16 static Returns the smaller of two 16-bit google brain floating-point numbers.
    • method static IsNaN(BFloat16 bfloat16) -> bool static Returns a value indicating whether the specified number evaluates to not a number (System.BFloat16.NaN).
    • method static IsInfinity(BFloat16 bfloat16) -> bool static Returns a value indicating whether the specified number evaluates to negative or positive infinity.
    • method static IsNegativeInfinity(BFloat16 bfloat16) -> bool static Returns a value indicating whether the specified number evaluates to negative infinity.
    • method static IsPositiveInfinity(BFloat16 bfloat16) -> boo static Returns a value indicating whether the specified number evaluates to positive infinity.
    • method static Parse(string value) -> BFloat16 static Converts the string representation of a number to its System.BFloat16 equivalent.
    • method static Parse(string value, IFormatProvider provider) -> BFloat16 static Converts the string representation of a number to its System.BFloat16 equivalent using the specified culture-specific format information.
    • method static Parse(string value, NumberStyles style) -> BFloat16 static Converts the string representation of a number in a specified style to its System.BFloat16 equivalent.
    • method static Parse(string value, NumberStyles style, IFormatProvider provider) -> BFloat16 static Converts the string representation of a number to its System.BFloat16 equivalent using the specified style and culture-specific format.
    • method static TryParse(string value, out BFloat16 result) -> bool static Converts the string representation of a number to its System.BFloat16 equivalent. A return value indicates whether the conversion succeeded or failed.
    • method static TryParse(string value, NumberStyles style, IFormatProvider provider, out BFloat16 result) -> bool static Converts the string representation of a number to its System.BFloat16 equivalent using the specified style and culture-specific format. A return value indicates whether the conversion succeeded or failed.
    • method ToString() -> string override Converts the numeric value of this instance to its equivalent string representation.
    • method ToString(IFormatProvider formatProvider) -> string override Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information.
    • method ToString(string format) -> string override Converts the numeric value of this instance to its equivalent string representation, using the specified format.
    • method ToString(string format, IFormatProvider formatProvider) -> string override Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific format information.
    • method IConvertible.ToSingle(IFormatProvider provider) -> float
    • method IConvertible.GetTypeCode() -> TypeCode
    • method IConvertible.ToBoolean(IFormatProvider provider) -> bool
    • method IConvertible.ToByte(IFormatProvider provider) -> byte
    • method IConvertible.ToChar(IFormatProvider provider) -> char
    • method IConvertible.ToDateTime(IFormatProvider provider) -> DateTime
    • method IConvertible.ToDecimal(IFormatProvider provider) -> decimal
    • method IConvertible.ToDouble(IFormatProvider provider) -> double
    • method IConvertible.ToInt16(IFormatProvider provider) -> short
    • method IConvertible.ToInt32(IFormatProvider provider) -> int
    • method IConvertible.ToInt64(IFormatProvider provider) -> long
    • method IConvertible.ToSByte(IFormatProvider provider) -> sbyte
    • method IConvertible.ToString(IFormatProvider provider) -> string
    • method IConvertible.ToType(Type conversionType, IFormatProvider provider) -> Type
    • method IConvertible.ToUInt16(IFormatProvider provider) -> ushort
    • method IConvertible.ToUInt32(IFormatProvider provider) -> uint
    • method IConvertible.ToUInt64(IFormatProvider provider) -> ulong

Code samples

  • Input and output of floating-point numbers. The simplest operations on them.
//reference System.FloatingPoint.dll or System.AI.dll
using System;

namespace FloatsExample
{

    public static class Program
    {

        public static void Main()
        {
            Console.Write("a = ");
            var a = Half.Parse(Console.ReadLine());
            Console.Write("b = ");
            var b = Quarter.Parse(Console.ReadLine());
            Console.Write("c = ");
            var c = BFloat16.Parse(Console.ReadLine());
            Console.WriteLine(string.Format("({0} + {1}) * {2} = {3}", a, b, c, (a + b) * c));
            Console.ReadKey(true);
        }

    }

}
  • BFloat16 matrix multiplication
//reference System.FloatingPoint.dll or System.AI.dll
using System;

namespace FloatMatrixExample
{

    public static class Program
    {

        public static BFloat16[,] MatMul(BFloat16[,] a, BFloat16[,] b)
        {
            var m = a.GetLength(0);
            var n = b.GetLength(1);
            var k = b.GetLength(0);
            var c = new BFloat16[m, n];
            for(int i = 0; i < m; ++i)
            {
                for(int z = 0; z < k; ++z)
                {
                    var av = a[i, z];
                    for(int j = 0; j < n; ++j)
                    {
                        c[i, j] += av * b[z, j];
                    }
                }
            }
            return c;
        }

        public static BFloat16[,] RandomMatrix(int m, int n)
        {
            var matrix = new BFloat16[m, n];
            var rand = new Random();
            for(int i = 0; i < m; ++i)
            {
                for(int j = 0; j < n; ++j)
                {
                    matrix[i, j] = (BFloat16)rand.NextDouble();
                }
            }
            return matrix;
        }

        public static void PrintMatrix(BFloat16[,] m)
        {
            var h = m.GetLength(0);
            var w = m.GetLength(1);
            for(int i = 0; i < h; ++i)
            {
                for(int j = 0; j < w; ++j)
                {
                    if((j + 1) < w)
                    {
                        Console.Write(string.Format("{0:f4}, ", m[i, j]));
                    }
                    else
                    {
                        Console.WriteLine(string.Format("{0:f4}", m[i, j]));
                    }
                }
            }
        }

        public static void Main()
        {
            const int m = 4;
            const int n = 7;
            const int k = 3;
            var a = RandomMatrix(m, n);
            Console.WriteLine("a=");
            PrintMatrix(a);
            var b = RandomMatrix(n, k);
            Console.WriteLine("\nb=");
            PrintMatrix(b);
            var c = MatMul(a, b);
            Console.WriteLine("\nc=");
            PrintMatrix(c);
            Console.ReadKey(true);
        }

    }

}

Technical details

Quarter(float8) is a 8-bit IEEE 754 floating point type. See https://en.wikipedia.org/wiki/Minifloat float8

Half(float16) is a 16-bit IEEE 754 floating point type. See https://en.wikipedia.org/wiki/Half-precision_floating-point_format float16

BFloat16 is a 16-bit Google Brain's floating point type for AI. Is a truncated version of Single(float32) type. See https://en.wikipedia.org/wiki/Bfloat16_floating-point_format bfloat16

Third-party codes as part of System.FloatingPoint

System.Half data type is a fully third-party code. Original source: https://sourceforge.net/projects/csharp-half/

In accordance with the license of the original System.Half code, the source code was refactored and included in the System.AI stack as an integral part.