Struct Half
- Namespace
- Stride.Core.Mathematics
- Assembly
- Stride.Core.Mathematics.dll
A half precision (16 bit) floating point value.
[DataContract]
public struct Half
Constructors
Half(float)
Initializes a new instance of the Half structure.
public Half(float value)
Parameters
value
floatThe floating point value that should be stored in 16 bit format.
Fields
AdditionRounding
Additional rounding.
public const int AdditionRounding = 1
Field Value
Epsilon
Smallest such that 1.0 + epsilon != 1.0
public static readonly float Epsilon
Field Value
ExponentRadix
Exponent radix.
public const int ExponentRadix = 2
Field Value
MantissaBits
Number of bits in the mantissa.
public const int MantissaBits = 11
Field Value
MaxValue
Maximum value of the number.
public static readonly float MaxValue
Field Value
MaximumBinaryExponent
Maximum binary exponent.
public const int MaximumBinaryExponent = 15
Field Value
MaximumDecimalExponent
Maximum decimal exponent.
public const int MaximumDecimalExponent = 4
Field Value
MinValue
Minimum value of the number.
public static readonly float MinValue
Field Value
MinimumBinaryExponent
Minimum binary exponent.
public const int MinimumBinaryExponent = -14
Field Value
MinimumDecimalExponent
Minimum decimal exponent.
public const int MinimumDecimalExponent = -4
Field Value
One
A Half whose value is 1.0f.
public static readonly Half One
Field Value
PrecisionDigits
Number of decimal digits of precision.
public const int PrecisionDigits = 3
Field Value
Zero
A Half whose value is 0.0f.
public static readonly Half Zero
Field Value
Properties
RawValue
Gets or sets the raw 16 bit value used to back this half-float.
public ushort RawValue { 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
values
Half[]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
values
float[]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 bool Equals(Half other)
Parameters
other
HalfObject to make the comparison with.
Returns
- bool
true
if the current instance is equal to the specified object;false
otherwise.
Equals(ref Half, ref Half)
Determines whether the specified object instances are considered equal.
public static bool Equals(ref Half value1, ref Half value2)
Parameters
Returns
- bool
true
ifvalue1
is the same instance asvalue2
or if both arenull
references or ifvalue1.Equals(value2)
returnstrue
; otherwise,false
.
Equals(object)
Returns a value that indicates whether the current instance is equal to a specified object.
public override bool Equals(object obj)
Parameters
obj
objectObject to make the comparison with.
Returns
- bool
true
if the current instance is equal to the specified object;false
otherwise.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer hash code.
ToString()
Converts the value of the object to its equivalent string representation.
public override string ToString()
Returns
- string
The string representation of the value of this instance.
Operators
operator ==(Half, Half)
Tests for equality between two objects.
public static bool operator ==(Half left, Half right)
Parameters
Returns
- bool
true
ifleft
has the same value asright
; otherwise,false
.
explicit operator Half(float)
public static explicit operator Half(float value)
Parameters
value
floatThe value to be converted.
Returns
- Half
The converted value.
implicit operator float(Half)
public static implicit operator float(Half value)
Parameters
value
HalfThe 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
true
ifleft
has a different value thanright
; otherwise,false
.