Struct Half
- Namespace
- Stride.Core.Mathematics
- Assembly
- Stride.Core.Mathematics.dll
A half precision (16 bit) floating point value.
[DataContract]
public struct Half : ISpanFormattable, IFormattable- Implements
Constructors
Half(float)
Initializes a new instance of the Half structure.
public Half(float value)Parameters
- valuefloat
- The floating point value that should be stored in 16 bit format. 
Fields
AdditionRounding
Additional rounding.
public const int AdditionRounding = 1Field Value
Epsilon
Smallest such that 1.0 + epsilon != 1.0
public static readonly float EpsilonField Value
ExponentRadix
Exponent radix.
public const int ExponentRadix = 2Field Value
MantissaBits
Number of bits in the mantissa.
public const int MantissaBits = 11Field Value
MaxValue
Maximum value of the number.
public static readonly float MaxValueField Value
MaximumBinaryExponent
Maximum binary exponent.
public const int MaximumBinaryExponent = 15Field Value
MaximumDecimalExponent
Maximum decimal exponent.
public const int MaximumDecimalExponent = 4Field Value
MinValue
Minimum value of the number.
public static readonly float MinValueField Value
MinimumBinaryExponent
Minimum binary exponent.
public const int MinimumBinaryExponent = -14Field Value
MinimumDecimalExponent
Minimum decimal exponent.
public const int MinimumDecimalExponent = -4Field Value
One
A Half whose value is 1.0f.
public static readonly Half OneField Value
PrecisionDigits
Number of decimal digits of precision.
public const int PrecisionDigits = 3Field Value
Zero
A Half whose value is 0.0f.
public static readonly Half ZeroField Value
Properties
RawValue
Gets or sets the raw 16 bit value used to back this half-float.
public ushort RawValue { readonly get; set; }Property Value
Methods
ConvertToFloat(Half[])
Converts an array of half precision values into full precision values.
public static float[] ConvertToFloat(Half[] values)Parameters
- valuesHalf[]
- The values to be converted. 
Returns
- float[]
- An array of converted values. 
ConvertToHalf(float[])
Converts an array of full precision values into half precision values.
public static Half[] ConvertToHalf(float[] values)Parameters
- valuesfloat[]
- The values to be converted. 
Returns
- Half[]
- An array of converted values. 
Equals(Half)
Returns a value that indicates whether the current instance is equal to the specified object.
public readonly bool Equals(Half other)Parameters
- otherHalf
- Object to make the comparison with. 
Returns
- bool
- trueif the current instance is equal to the specified object;- falseotherwise.
Equals(ref readonly Half, ref readonly Half)
Determines whether the specified object instances are considered equal.
public static bool Equals(ref readonly Half value1, ref readonly Half value2)Parameters
Returns
- bool
- trueif- value1is the same instance as- value2or if both are- nullreferences or if- value1.Equals(value2)returns- true; otherwise,- false.
Equals(object?)
Returns a value that indicates whether the current instance is equal to a specified object.
public override readonly bool Equals(object? obj)Parameters
- objobject
- Object to make the comparison with. 
Returns
- bool
- trueif the current instance is equal to the specified object;- falseotherwise.
GetHashCode()
Returns the hash code for this instance.
public override readonly int GetHashCode()Returns
- int
- A 32-bit signed integer hash code. 
ToString()
Returns a string that represents this instance.
public override readonly string ToString()Returns
ToString(string?, IFormatProvider?)
Returns a string that represents this instance.
public readonly string ToString(string? format, IFormatProvider? formatProvider)Parameters
- formatstring
- The format. 
- formatProviderIFormatProvider
- The format provider. 
Returns
Operators
operator ==(Half, Half)
Tests for equality between two objects.
public static bool operator ==(Half left, Half right)Parameters
Returns
- bool
- trueif- lefthas the same value as- right; otherwise,- false.
explicit operator Half(float)
public static explicit operator Half(float value)Parameters
- valuefloat
- The value to be converted. 
Returns
- Half
- The converted value. 
implicit operator float(Half)
public static implicit operator float(Half value)Parameters
- valueHalf
- The value to be converted. 
Returns
- float
- The converted value. 
operator !=(Half, Half)
Tests for inequality between two objects.
public static bool operator !=(Half left, Half right)Parameters
Returns
- bool
- trueif- lefthas a different value than- right; otherwise,- false.