Photon Quantum 3.0.0

Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Properties | List of all members
Photon.Deterministic.FP Struct Reference

A fixed-point number. 16 lower bits are used for the decimal part, 48 for the integral part. More...

Classes

class  Comparer
 Compares FPs. More...
 
class  EqualityComparer
 Equality comparer for FPs. More...
 
class  Raw
 Holds FP constants in raw (long) form. More...
 

Public Member Functions

Int32 CompareTo (FP other)
 Compares this instance of FP to another instance and returns an integer that indicates whether this instance is less than, equal to, or greater than the other instance. More...
 
Boolean Equals (FP other)
 Determines whether the current instance is equal to another instance of FP. More...
 
override Boolean Equals (Object obj)
 Determines whether the current instance of FP is equal to the specified object. More...
 
override Int32 GetHashCode ()
 Computes the hash code for the current instance of the FP struct. More...
 
override string ToString ()
 Returns a string representation of the current FP value. More...
 
String ToString (string format)
 Returns a string that represents the FP. More...
 
String ToStringInternal ()
 Returns a string that represents the FP using a custom format. More...
 
string ToStringLegacy ()
 Converts the value of the current FP object to its equivalent string representation using the legacy format. More...
 

Static Public Member Functions

static FP FromDouble_UNSAFE (double value)
 Converts a double value to an instance of the FP, with rounding towards zero.. To round towards nearest representable FP, use FromRoundedDouble_UNSAFE. This method is marked as unsafe because it is not deterministic. More...
 
static FP FromFloat_UNSAFE (Single value)
 Converts a single-precision floating-point value to an instance of the FP, with rounding towards zero.. To round towards nearest representable FP, use FromRoundedFloat_UNSAFE. This method is marked as unsafe because it is not deterministic. More...
 
static FP FromRaw (Int64 value)
 Converts a raw integer value to an instance of FP. More...
 
static FP FromRoundedDouble_UNSAFE (double value)
 Converts a double value to an instance of the FP, with rounding to the nearest representable FP. More...
 
static FP FromRoundedFloat_UNSAFE (float value)
 Converts a single-precision floating-point value to an instance of the FP, with rounding to the nearest representable FP. This method is marked as unsafe because it is not deterministic. More...
 
static FP FromString (String value)
 Converts a string representation of a fixed-point number to an instance of the FP struct. More...
 
static FP FromString_UNSAFE (String value)
 Creates an instance of FP from a string representation of a float value. This method is marked as unsafe because it is not deterministic. More...
 
static operator Double (FP value)
 Converts an FP value to a double value. More...
 
static implicit operator FP (Byte value)
 Implicit conversion operator for converting a Byte value to an FP (Fixed Point) value. More...
 
static implicit operator FP (double value)
 Purposefully throws an exception when trying to cast from a double to an FP. More...
 
static implicit operator FP (float value)
 Purposefully throws an exception when trying to cast from a float to an FP. More...
 
static implicit operator FP (Int16 value)
 Converts an integer value to an FP value. More...
 
static implicit operator FP (Int32 value)
 Converts an integer value to an FP value. More...
 
static implicit operator FP (SByte value)
 Implicitly converts a signed byte value to an instance of the FP struct. More...
 
static implicit operator FP (UInt16 value)
 Converts an integer value to an FP value. More...
 
static implicit operator FP (UInt32 value)
 Converts an integer value to an FP value. More...
 
static operator Int32 (FP value)
 Converts an integer value to an FP value. More...
 
static operator Int64 (FP value)
 Converts an FP value to an integer value. More...
 
static operator Single (FP value)
 Converts an FP value to a float value. More...
 
static Boolean operator!= (FP a, FP b)
 Compares two FP values for inequality. More...
 
static Boolean operator!= (FP a, Int32 b)
 Compares an FP value with an integer value for inequality. More...
 
static Boolean operator!= (Int32 a, FP b)
 Compares an integer value with an FP value for inequality. More...
 
static FP operator% (FP a, FP b)
 Modulo operator for FP values. More...
 
static FP operator% (FP a, FPHighPrecisionDivisor b)
 Modulo operator for FP and high precision divisor. More...
 
static FP operator% (FP a, Int32 b)
 Modulo operator for FP and integer values. More...
 
static FP operator% (Int32 a, FP b)
 Modulo operator for integer and FP values. More...
 
static FP operator* (FP a, FP b)
 Represents the operator to multiply two FP values. More...
 
static FP operator* (FP a, Int32 b)
 Represents the operator for multiplying a floating-point value by an integer value. More...
 
static FP operator* (Int32 a, FP b)
 Multiplies an integer value by an FP value. More...
 
static FP operator+ (FP a)
 Converts the value to its absolute version. More...
 
static FP operator+ (FP a, FP b)
 Represents the operator to add two FP values. More...
 
static FP operator+ (FP a, Int32 b)
 Overloads the addition operator to add an integer value to an FP value. More...
 
static FP operator+ (Int32 a, FP b)
 Represents the operator overloading for adding an integer and an FP value. More...
 
static FP operator- (FP a)
 Negates the value. More...
 
static FP operator- (FP a, FP b)
 Subtracts two FP (fixed point) values. More...
 
static FP operator- (FP a, Int32 b)
 Subtracts an integer value from an FP value. More...
 
static FP operator- (Int32 a, FP b)
 Represents an overloaded operator for negating the value of an integer. More...
 
static FP operator/ (FP a, FP b)
 Represents an operator to perform division on two FP (fixed point) numbers. More...
 
static FP operator/ (FP a, FPHighPrecisionDivisor b)
 Divides an FP value by a high precision divisor. More...
 
static FP operator/ (FP a, Int32 b)
 Divides an FP value by an integer value. More...
 
static FP operator/ (Int32 a, FP b)
 This operator takes an integer value (a) and an FP value (b) and returns the result of the division of a by b. More...
 
static Boolean operator< (FP a, FP b)
 Represents the operator to compare two FP values. More...
 
static Boolean operator< (FP a, Int32 b)
 Represents the operator to compare an FP value with an integer value. More...
 
static Boolean operator< (Int32 a, FP b)
 Represents the operator to compare an integer value with an FP value. More...
 
static Boolean operator<= (FP a, FP b)
 Represents the operator to compare two FP values. More...
 
static Boolean operator<= (FP a, Int32 b)
 Code that defines the operator for less than or equal to comparison between a FP (Fixed Point) value and an integer value. More...
 
static Boolean operator<= (Int32 a, FP b)
 Code that defines the operator for less than or equal to comparison between an integer value and a FP (Fixed Point) value. More...
 
static Boolean operator== (FP a, FP b)
 Compares two FP values for equality. More...
 
static Boolean operator== (FP a, Int32 b)
 Compares an FP value with an integer value for equality. More...
 
static Boolean operator== (Int32 a, FP b)
 Compares an integer value with an FP value for equality. More...
 
static Boolean operator> (FP a, FP b)
 Represents the operator to compare two FP values. More...
 
static Boolean operator> (FP a, Int32 b)
 Represents the operator to compare an FP value with an integer value. More...
 
static Boolean operator> (Int32 a, FP b)
 Represents the operator to compare an integer value with an FP value. More...
 
static Boolean operator>= (FP a, FP b)
 Represents the operator to compare two FP values. More...
 
static Boolean operator>= (FP a, Int32 b)
 Represents the operator to compare an FP value with an integer value. More...
 
static Boolean operator>= (Int32 a, FP b)
 Represents the operator to compare an integer value with an FP value. More...
 
static unsafe void Serialize (void *ptr, IDeterministicFrameSerializer serializer)
 Serializes the given pointer using the provided serializer. More...
 

Public Attributes

Int64 RawValue
 The raw integer value of the fixed-point number. More...
 

Static Public Attributes

const int Bits = sizeof(long) * 8
 The size in bits of the fixed-point number. (64) More...
 
const long MulRound = (1 << (Precision - 1))
 Represents the value of the rounding constant used in Fixed Point multiplication. More...
 
const int MulShift = Precision
 Represents the bit shift used in Fixed Point multiplication. More...
 
const int Precision = FPLut.PRECISION
 Represents the precision used for Fixed Point calculations. More...
 
const long RAW_ONE = FPLut.ONE
 The value of one as a fixed-point number. More...
 
const long RAW_ZERO = 0
 Represents a constant that holds the raw value of zero for the FP struct. More...
 
const int SIZE = 8
 Represents the size of a variable in bytes. More...
 

Properties

static FP _0 [get]
 FP constant representing the number 0. More...
 
static FP _0_01 [get]
 FP constant representing the number 0.01. More...
 
static FP _0_02 [get]
 FP constant representing the number 0.02. More...
 
static FP _0_03 [get]
 FP constant representing the number 0.03. More...
 
static FP _0_04 [get]
 FP constant representing the number 0.04. More...
 
static FP _0_05 [get]
 FP constant representing the number 0.05. More...
 
static FP _0_10 [get]
 FP constant representing the number 0.10. More...
 
static FP _0_20 [get]
 FP constant representing the number 0.20. More...
 
static FP _0_25 [get]
 FP constant representing the number 0.25. More...
 
static FP _0_33 [get]
 FP constant representing the number 0.33. More...
 
static FP _0_50 [get]
 FP constant representing the number 0.50. More...
 
static FP _0_75 [get]
 FP constant representing the number 0.75. More...
 
static FP _0_99 [get]
 FP constant representing the number 0.99. More...
 
static FP _1 [get]
 FP constant representing the number 1. More...
 
static FP _10 [get]
 FP constant representing the number 10. More...
 
static FP _100 [get]
 FP constant representing the number 100. More...
 
static FP _1000 [get]
 FP constant representing the number 1000. More...
 
static FP _10000 [get]
 FP constant representing the number 10000. More...
 
static FP _180 [get]
 FP constant representing the number 180. More...
 
static FP _1_01 [get]
 FP constant representing the number 1.01. More...
 
static FP _1_02 [get]
 FP constant representing the number 1.02. More...
 
static FP _1_03 [get]
 FP constant representing the number 1.03. More...
 
static FP _1_04 [get]
 FP constant representing the number 1.04. More...
 
static FP _1_05 [get]
 FP constant representing the number 1.05. More...
 
static FP _1_10 [get]
 FP constant representing the number 1.10. More...
 
static FP _1_20 [get]
 FP constant representing the number 1.20. More...
 
static FP _1_25 [get]
 FP constant representing the number 1.25. More...
 
static FP _1_33 [get]
 FP constant representing the number 1.33. More...
 
static FP _1_50 [get]
 FP constant representing the number 1.50. More...
 
static FP _1_75 [get]
 FP constant representing the number 1.75. More...
 
static FP _1_99 [get]
 FP constant representing the number 1.99. More...
 
static FP _2 [get]
 FP constant representing the number 2. More...
 
static FP _200 [get]
 FP constant representing the number 200. More...
 
static FP _3 [get]
 FP constant representing the number 3. More...
 
static FP _360 [get]
 FP constant representing the number 360. More...
 
static FP _4 [get]
 FP constant representing the number 4. More...
 
static FP _5 [get]
 FP constant representing the number 5. More...
 
static FP _6 [get]
 FP constant representing the number 6. More...
 
static FP _7 [get]
 FP constant representing the number 7. More...
 
static FP _8 [get]
 FP constant representing the number 8. More...
 
static FP _9 [get]
 FP constant representing the number 9. More...
 
static FP _99 [get]
 FP constant representing the number 99. More...
 
Double AsDouble [get]
 Converts to double. More...
 
Single AsFloat [get]
 Converts to float. More...
 
Int32 AsInt [get]
 Return integral part as int. More...
 
Int64 AsLong [get]
 Returns integral part as long. More...
 
double AsRoundedDouble [get]
 Converts to double. The returned value is not exact, but rather the one that has the least significant digits given FP's precision. More...
 
Int16 AsShort [get]
 Return integral part as int. More...
 
static FP Deg2Rad [get]
 Degrees-to-radians conversion constant. More...
 
static FP E [get]
 FP constant representing the Euler Number constant. More...
 
static FP EN1 [get]
 FP constant representing the epsilon value EN1. More...
 
static FP EN2 [get]
 FP constant representing the epsilon value EN2. More...
 
static FP EN3 [get]
 FP constant representing the epsilon value EN3. More...
 
static FP EN4 [get]
 FP constant representing the epsilon value EN4. More...
 
static FP EN5 [get]
 FP constant representing the epsilon value EN5. More...
 
static FP Epsilon [get]
 FP constant representing Epsilon EN3. More...
 
static FP Log2_10 [get]
 FP constant representing Log(10). More...
 
static FP Log2_E [get]
 FP constant representing Log(E). More...
 
static FP MaxValue [get]
 Maximum FP value, but values outside of UseableMin and UseableMax (inclusive) can overflow when multiplied. More...
 
static FP Minus_1 [get]
 FP constant representing the number -1. More...
 
static FP MinValue [get]
 Minimum FP value, but values outside of UseableMin and UseableMax (inclusive) can overflow when multiplied. More...
 
static FP Pi [get]
 Pi number. More...
 
static FP Pi3Over4 [get]
 3 * Pi / 4. More...
 
static FP Pi4Over3 [get]
 4 * Pi / 3. More...
 
static FP PiInv [get]
 1/Pi. More...
 
static FP PiOver2 [get]
 Pi / 2. More...
 
static FP PiOver2Inv [get]
 2 / Pi. More...
 
static FP PiOver4 [get]
 Pi / 4. More...
 
static FP PiTimes2 [get]
 2 * Pi. More...
 
static FP Rad2Deg [get]
 Radians-to-degrees conversion constant. More...
 
static FP Rad_180 [get]
 FP constant representing 180 degrees in radian. More...
 
static FP Rad_22_50 [get]
 FP constant representing 22.5 degrees in radian. More...
 
static FP Rad_360 [get]
 FP constant representing 360 degrees in radian. More...
 
static FP Rad_45 [get]
 FP constant representing 45 degrees in radian. More...
 
static FP Rad_90 [get]
 FP constant representing 90 degrees in radian. More...
 
static FP SmallestNonZero [get]
 The smallest FP unit that is not 0. More...
 
static FP UseableMax [get]
 Represents the highest FP number that can be multiplied with itself and not cause an overflow (exceeding long range). More...
 
static FP UseableMin [get]
 Represents the highest negative FP number that can be multiplied with itself and not cause an overflow (exceeding long range). More...
 

Detailed Description

A fixed-point number. 16 lower bits are used for the decimal part, 48 for the integral part.

It provides various methods for performing mathematical operations and converting between different data types.

However, a majority of internal code and the multiplication operator perform fast multiplication, where the result can use at most 32 bits for the integral part and overflows are not detected. This means that you should stay in System.Int16 range.

See also
FP.UseableMax, FP.UseableMin

The precision of the decimal part is 5 digits. The decimal fraction normalizer is 1E5. The size of an FP object is 8 bytes. The raw value of one is equal to FPLut.ONE. The raw value of zero is 0. The precision value is equal to FPLut.PRECISION. The number of bits in an FP object is equal to the size of a long (64 bits). The MulRound constant is 0. The MulShift constant is equal to the precision value. The MulShiftTrunc constant is equal to the precision value. The UsesRoundedConstants constant is either true or false, depending on the value of PHOTONDETERMINISTIC_FP_OLD_CONSTANTS.

See also
FPLut

true

Member Function Documentation

◆ Serialize()

static unsafe void Photon.Deterministic.FP.Serialize ( void *  ptr,
IDeterministicFrameSerializer  serializer 
)
inlinestatic

Serializes the given pointer using the provided serializer.

Parameters
ptrThe pointer to the FP object to be serialized.
serializerThe serializer used for serialization.

◆ CompareTo()

Int32 Photon.Deterministic.FP.CompareTo ( FP  other)
inline

Compares this instance of FP to another instance and returns an integer that indicates whether this instance is less than, equal to, or greater than the other instance.

Parameters
otherThe other instance to compare.
Returns
A signed integer that indicates the relative values of this instance and the other instance.

◆ Equals() [1/2]

Boolean Photon.Deterministic.FP.Equals ( FP  other)
inline

Determines whether the current instance is equal to another instance of FP.

Parameters
otherThe instance to compare with the current instance.
Returns
true if the current instance is equal to the other instance; otherwise, false.

◆ Equals() [2/2]

override Boolean Photon.Deterministic.FP.Equals ( Object  obj)
inline

Determines whether the current instance of FP is equal to the specified object.

Parameters
objThe object to compare with the current instance of FP.
Returns
true if the specified object is equal to the current instance of FP; otherwise, false.

◆ GetHashCode()

override Int32 Photon.Deterministic.FP.GetHashCode ( )
inline

Computes the hash code for the current instance of the FP struct.

Returns
A 32-bit signed integer hash code.

◆ ToString() [1/2]

override string Photon.Deterministic.FP.ToString ( )
inline

Returns a string representation of the current FP value.

Returns
A string representation of the current FP value.

◆ ToStringLegacy()

string Photon.Deterministic.FP.ToStringLegacy ( )
inline

Converts the value of the current FP object to its equivalent string representation using the legacy format.

Returns
The string representation of the value of the current FP object, formatted using the legacy format.

◆ ToString() [2/2]

String Photon.Deterministic.FP.ToString ( string  format)
inline

Returns a string that represents the FP.

Returns
String representation of the FP.

◆ ToStringInternal()

String Photon.Deterministic.FP.ToStringInternal ( )
inline

Returns a string that represents the FP using a custom format.

Returns
String representation of the FP.

◆ FromRoundedDouble_UNSAFE()

static FP Photon.Deterministic.FP.FromRoundedDouble_UNSAFE ( double  value)
inlinestatic

Converts a double value to an instance of the FP, with rounding to the nearest representable FP.

Parameters
valueThe rounded double value to convert.
Returns
The FP value that represents the rounded double value.

◆ FromDouble_UNSAFE()

static FP Photon.Deterministic.FP.FromDouble_UNSAFE ( double  value)
inlinestatic

Converts a double value to an instance of the FP, with rounding towards zero.. To round towards nearest representable FP, use FromRoundedDouble_UNSAFE. This method is marked as unsafe because it is not deterministic.

Parameters
valueThe double value to convert.
Returns
An instance of the FP struct that represents the converted value.

◆ FromRoundedFloat_UNSAFE()

static FP Photon.Deterministic.FP.FromRoundedFloat_UNSAFE ( float  value)
inlinestatic

Converts a single-precision floating-point value to an instance of the FP, with rounding to the nearest representable FP. This method is marked as unsafe because it is not deterministic.

Parameters
valueThe value to convert.
Returns
The converted value.

◆ FromFloat_UNSAFE()

static FP Photon.Deterministic.FP.FromFloat_UNSAFE ( Single  value)
inlinestatic

Converts a single-precision floating-point value to an instance of the FP, with rounding towards zero.. To round towards nearest representable FP, use FromRoundedFloat_UNSAFE. This method is marked as unsafe because it is not deterministic.

Parameters
valueThe value to convert.
Returns
The converted value.

◆ FromRaw()

static FP Photon.Deterministic.FP.FromRaw ( Int64  value)
inlinestatic

Converts a raw integer value to an instance of FP.

Parameters
valueThe raw integer value to convert.
Returns
A new instance of FP that represents the same value as the raw integer.

◆ FromString_UNSAFE()

static FP Photon.Deterministic.FP.FromString_UNSAFE ( String  value)
inlinestatic

Creates an instance of FP from a string representation of a float value. This method is marked as unsafe because it is not deterministic.

Parameters
valueThe string representation of the float value.
Returns
An instance of FP representing the float value.

◆ FromString()

static FP Photon.Deterministic.FP.FromString ( String  value)
inlinestatic

Converts a string representation of a fixed-point number to an instance of the FP struct.

Parameters
value
Returns
Exceptions
FormatException

◆ operator-() [1/4]

static FP Photon.Deterministic.FP.operator- ( FP  a)
inlinestatic

Negates the value.

◆ operator+() [1/4]

static FP Photon.Deterministic.FP.operator+ ( FP  a)
inlinestatic

Converts the value to its absolute version.

FP.Operators.cs

◆ operator+() [2/4]

static FP Photon.Deterministic.FP.operator+ ( FP  a,
FP  b 
)
inlinestatic

Represents the operator to add two FP values.

Parameters
aThe first FP value.
bThe second FP value.
Returns
The sum of the two FP values.

◆ operator+() [3/4]

static FP Photon.Deterministic.FP.operator+ ( FP  a,
Int32  b 
)
inlinestatic

Overloads the addition operator to add an integer value to an FP value.

Parameters
aThe FP value.
bThe integer value to add.
Returns
The result of adding the integer value to the FP value.

◆ operator+() [4/4]

static FP Photon.Deterministic.FP.operator+ ( Int32  a,
FP  b 
)
inlinestatic

Represents the operator overloading for adding an integer and an FP value.

Parameters
aThe integer value.
bThe FP value.
Returns
The result of adding the integer and FP values.

◆ operator-() [2/4]

static FP Photon.Deterministic.FP.operator- ( FP  a,
FP  b 
)
inlinestatic

Subtracts two FP (fixed point) values.

Parameters
aThe first FP value.
bThe second FP value.
Returns
The result of subtracting the second FP value from the first FP value.

◆ operator-() [3/4]

static FP Photon.Deterministic.FP.operator- ( FP  a,
Int32  b 
)
inlinestatic

Subtracts an integer value from an FP value.

Parameters
aThe FP value.
bThe integer value.
Returns

◆ operator-() [4/4]

static FP Photon.Deterministic.FP.operator- ( Int32  a,
FP  b 
)
inlinestatic

Represents an overloaded operator for negating the value of an integer.

Parameters
aThe integer value to be negated.
bThe FP value to subtract from.
Returns
The result of subtracting the FP value from the negated integer value.

This operator subtracts the FP value from the negated integer value by shifting the integer value to the left by the precision of FP, then subtracting the raw value of FP from it. The result is then returned as a new FP value.

◆ operator*() [1/3]

static FP Photon.Deterministic.FP.operator* ( FP  a,
FP  b 
)
inlinestatic

Represents the operator to multiply two FP values.

Parameters
aThe first FP value.
bThe Second FP value
Returns
The product.

◆ operator*() [2/3]

static FP Photon.Deterministic.FP.operator* ( FP  a,
Int32  b 
)
inlinestatic

Represents the operator for multiplying a floating-point value by an integer value.

Parameters
aThe floating-point value.
bThe integer value.
Returns
The result of multiplying the floating-point value by the integer value.

◆ operator*() [3/3]

static FP Photon.Deterministic.FP.operator* ( Int32  a,
FP  b 
)
inlinestatic

Multiplies an integer value by an FP value.

◆ operator/() [1/4]

static FP Photon.Deterministic.FP.operator/ ( FP  a,
FP  b 
)
inlinestatic

Represents an operator to perform division on two FP (fixed point) numbers.

Parameters
aThe dividend.
bThe divisor.
Returns
The result of the division operation.

◆ operator/() [2/4]

static FP Photon.Deterministic.FP.operator/ ( FP  a,
Int32  b 
)
inlinestatic

Divides an FP value by an integer value.

Parameters
aThe first FP value.
bThe second Int32 value.
Returns
The divided result.

◆ operator/() [3/4]

static FP Photon.Deterministic.FP.operator/ ( Int32  a,
FP  b 
)
inlinestatic

This operator takes an integer value (a) and an FP value (b) and returns the result of the division of a by b.

Parameters
aThe integer value to be divided.
bThe FP value to divide by.
Returns
An FP value representing the result of the division of a by b.

◆ operator/() [4/4]

static FP Photon.Deterministic.FP.operator/ ( FP  a,
FPHighPrecisionDivisor  b 
)
inlinestatic

Divides an FP value by a high precision divisor.

Parameters
aThe FP value.
bThe HighPrecisionDivisor.
Returns
The result.

◆ operator%() [1/4]

static FP Photon.Deterministic.FP.operator% ( FP  a,
FP  b 
)
inlinestatic

Modulo operator for FP values.

◆ operator%() [2/4]

static FP Photon.Deterministic.FP.operator% ( FP  a,
Int32  b 
)
inlinestatic

Modulo operator for FP and integer values.

Parameters
aThe FP value.
bThe integer value.
Returns

◆ operator%() [3/4]

static FP Photon.Deterministic.FP.operator% ( Int32  a,
FP  b 
)
inlinestatic

Modulo operator for integer and FP values.

Parameters
aThe integer value.
bThe FP value.

◆ operator%() [4/4]

static FP Photon.Deterministic.FP.operator% ( FP  a,
FPHighPrecisionDivisor  b 
)
inlinestatic

Modulo operator for FP and high precision divisor.

Parameters
aThe FP value.
bThe high precision divisor.
Returns

◆ operator<() [1/3]

static Boolean Photon.Deterministic.FP.operator< ( FP  a,
FP  b 
)
inlinestatic

Represents the operator to compare two FP values.

Parameters
aThe first FP value.
bThe second FP value.
Returns

◆ operator<() [2/3]

static Boolean Photon.Deterministic.FP.operator< ( FP  a,
Int32  b 
)
inlinestatic

Represents the operator to compare an FP value with an integer value.

Parameters
aThe FP value.
bThe integer value.
Returns

◆ operator<() [3/3]

static Boolean Photon.Deterministic.FP.operator< ( Int32  a,
FP  b 
)
inlinestatic

Represents the operator to compare an integer value with an FP value.

Parameters
aThe integer value.
bThe FP value.
Returns

◆ operator<=() [1/3]

static Boolean Photon.Deterministic.FP.operator<= ( FP  a,
FP  b 
)
inlinestatic

Represents the operator to compare two FP values.

Parameters
aThe first FP value.
bThe second FP value.
Returns

◆ operator<=() [2/3]

static Boolean Photon.Deterministic.FP.operator<= ( FP  a,
Int32  b 
)
inlinestatic

Code that defines the operator for less than or equal to comparison between a FP (Fixed Point) value and an integer value.

Parameters
aThe FP value to compare
bThe integer value to compare
Returns
Returns true if the FP value is less than or equal to the integer value, otherwise false

◆ operator<=() [3/3]

static Boolean Photon.Deterministic.FP.operator<= ( Int32  a,
FP  b 
)
inlinestatic

Code that defines the operator for less than or equal to comparison between an integer value and a FP (Fixed Point) value.

Parameters
aThe integer value to compare
bThe FP value to compare
Returns
Returns true if the integer value is less than or equal to the FP value, otherwise false

◆ operator>() [1/3]

static Boolean Photon.Deterministic.FP.operator> ( FP  a,
FP  b 
)
inlinestatic

Represents the operator to compare two FP values.

Parameters
aThe first FP value.
bThe second FP value.
Returns
true if the first value is greater than the second, otherwise false.

◆ operator>() [2/3]

static Boolean Photon.Deterministic.FP.operator> ( FP  a,
Int32  b 
)
inlinestatic

Represents the operator to compare an FP value with an integer value.

Parameters
aThe FP value.
bThe integer value.
Returns
true if the FP value is greater than the integer value, otherwise false.

◆ operator>() [3/3]

static Boolean Photon.Deterministic.FP.operator> ( Int32  a,
FP  b 
)
inlinestatic

Represents the operator to compare an integer value with an FP value.

Parameters
aThe integer value.
bThe FP value.
Returns
true if the integer value is greater than the FP value, otherwise false.

◆ operator>=() [1/3]

static Boolean Photon.Deterministic.FP.operator>= ( FP  a,
FP  b 
)
inlinestatic

Represents the operator to compare two FP values.

Parameters
aThe first FP value.
bThe second FP value.
Returns
true if the first value is greater than or equal to the second, otherwise false.

◆ operator>=() [2/3]

static Boolean Photon.Deterministic.FP.operator>= ( FP  a,
Int32  b 
)
inlinestatic

Represents the operator to compare an FP value with an integer value.

Parameters
aThe FP value.
bThe integer value.
Returns
true if the FP value is greater than or equal to the integer value, otherwise false.

◆ operator>=() [3/3]

static Boolean Photon.Deterministic.FP.operator>= ( Int32  a,
FP  b 
)
inlinestatic

Represents the operator to compare an integer value with an FP value.

Parameters
aThe integer value.
bThe FP value.
Returns
true if the integer value is greater than or equal to the FP value, otherwise false.

◆ operator==() [1/3]

static Boolean Photon.Deterministic.FP.operator== ( FP  a,
FP  b 
)
inlinestatic

Compares two FP values for equality.

Parameters
aThe first FP value.
bThe second FP value.
Returns
true if the two values are equal, otherwise false.

◆ operator==() [2/3]

static Boolean Photon.Deterministic.FP.operator== ( FP  a,
Int32  b 
)
inlinestatic

Compares an FP value with an integer value for equality.

Parameters
aThe FP value.
bThe integer value.
Returns
true if the two values are equal, otherwise false.

◆ operator==() [3/3]

static Boolean Photon.Deterministic.FP.operator== ( Int32  a,
FP  b 
)
inlinestatic

Compares an integer value with an FP value for equality.

Parameters
aThe integer value.
bThe FP value.
Returns
true if the two values are equal, otherwise false.

◆ operator!=() [1/3]

static Boolean Photon.Deterministic.FP.operator!= ( FP  a,
FP  b 
)
inlinestatic

Compares two FP values for inequality.

Parameters
aThe first FP value.
bThe second FP value.
Returns
true if the two values are not equal, otherwise false.

◆ operator!=() [2/3]

static Boolean Photon.Deterministic.FP.operator!= ( FP  a,
Int32  b 
)
inlinestatic

Compares an FP value with an integer value for inequality.

Parameters
aThe FP value.
bThe integer value.
Returns
true if the two values are not equal, otherwise false.

◆ operator!=() [3/3]

static Boolean Photon.Deterministic.FP.operator!= ( Int32  a,
FP  b 
)
inlinestatic

Compares an integer value with an FP value for inequality.

Parameters
aThe integer value.
bThe FP value.
Returns
true if the two values are not equal, otherwise false.

◆ operator FP() [1/8]

static implicit Photon.Deterministic.FP.operator FP ( Int32  value)
inlinestatic

Converts an integer value to an FP value.

Parameters
valueThe integer value to convert.
Returns
The FP value.

◆ operator FP() [2/8]

static implicit Photon.Deterministic.FP.operator FP ( UInt32  value)
inlinestatic

Converts an integer value to an FP value.

Parameters
valueThe integer value to convert.
Returns
The FP value.

◆ operator FP() [3/8]

static implicit Photon.Deterministic.FP.operator FP ( Int16  value)
inlinestatic

Converts an integer value to an FP value.

Parameters
valueThe integer value to convert.

◆ operator FP() [4/8]

static implicit Photon.Deterministic.FP.operator FP ( UInt16  value)
inlinestatic

Converts an integer value to an FP value.

Parameters
valueThe integer value to convert.
Returns
The FP value.

◆ operator FP() [5/8]

static implicit Photon.Deterministic.FP.operator FP ( SByte  value)
inlinestatic

Implicitly converts a signed byte value to an instance of the FP struct.

Parameters
valueThe signed byte value to be converted.
Returns
An instance of the FP struct representing the converted value.

◆ operator FP() [6/8]

static implicit Photon.Deterministic.FP.operator FP ( Byte  value)
inlinestatic

Implicit conversion operator for converting a Byte value to an FP (Fixed Point) value.

Parameters
valueThe Byte value to be converted.
Returns
An FP value representing the converted Byte value.

◆ operator Int32()

static Photon.Deterministic.FP.operator Int32 ( FP  value)
inlineexplicitstatic

Converts an integer value to an FP value.

Parameters
valueThe integer value to convert.
Returns
The FP value.

◆ operator Int64()

static Photon.Deterministic.FP.operator Int64 ( FP  value)
inlineexplicitstatic

Converts an FP value to an integer value.

Parameters
valueThe FP value to convert.
Returns
The integer value.

◆ operator Single()

static Photon.Deterministic.FP.operator Single ( FP  value)
inlineexplicitstatic

Converts an FP value to a float value.

Parameters
valueThe FP value to convert.
Returns
The float value.

◆ operator Double()

static Photon.Deterministic.FP.operator Double ( FP  value)
inlineexplicitstatic

Converts an FP value to a double value.

Parameters
valueThe FP value to convert.
Returns
The double value.

◆ operator FP() [7/8]

static implicit Photon.Deterministic.FP.operator FP ( float  value)
static

Purposefully throws an exception when trying to cast from a float to an FP.

Parameters
value
Returns
Exceptions
InvalidOperationException

◆ operator FP() [8/8]

static implicit Photon.Deterministic.FP.operator FP ( double  value)
static

Purposefully throws an exception when trying to cast from a double to an FP.

Parameters
value
Returns
Exceptions
InvalidOperationException

Member Data Documentation

◆ SIZE

const int Photon.Deterministic.FP.SIZE = 8
static

Represents the size of a variable in bytes.

The SIZE constant is used to determine the size of a variable in bytes.

◆ RAW_ONE

const long Photon.Deterministic.FP.RAW_ONE = FPLut.ONE
static

The value of one as a fixed-point number.

◆ RAW_ZERO

const long Photon.Deterministic.FP.RAW_ZERO = 0
static

Represents a constant that holds the raw value of zero for the FP struct.

◆ Precision

const int Photon.Deterministic.FP.Precision = FPLut.PRECISION
static

Represents the precision used for Fixed Point calculations.

The Precision constant is used to determine the number of decimal places in Fixed Point calculations.

◆ Bits

const int Photon.Deterministic.FP.Bits = sizeof(long) * 8
static

The size in bits of the fixed-point number. (64)

◆ MulRound

const long Photon.Deterministic.FP.MulRound = (1 << (Precision - 1))
static

Represents the value of the rounding constant used in Fixed Point multiplication.

◆ MulShift

const int Photon.Deterministic.FP.MulShift = Precision
static

Represents the bit shift used in Fixed Point multiplication.

◆ RawValue

Int64 Photon.Deterministic.FP.RawValue

The raw integer value of the fixed-point number.

Property Documentation

◆ SmallestNonZero

FP Photon.Deterministic.FP.SmallestNonZero
staticget

The smallest FP unit that is not 0.

Closest double: 1.52587890625E-05

◆ MinValue

FP Photon.Deterministic.FP.MinValue
staticget

Minimum FP value, but values outside of UseableMin and UseableMax (inclusive) can overflow when multiplied.

Closest double: -140737488355328

◆ MaxValue

FP Photon.Deterministic.FP.MaxValue
staticget

Maximum FP value, but values outside of UseableMin and UseableMax (inclusive) can overflow when multiplied.

Closest double: 140737488355328

◆ UseableMin

FP Photon.Deterministic.FP.UseableMin
staticget

Represents the highest negative FP number that can be multiplied with itself and not cause an overflow (exceeding long range).

Closest double: -32768

◆ UseableMax

FP Photon.Deterministic.FP.UseableMax
staticget

Represents the highest FP number that can be multiplied with itself and not cause an overflow (exceeding long range).

Closest double: 32767.9999847412

◆ Pi

FP Photon.Deterministic.FP.Pi
staticget

Pi number.

Closest double: 3.14158630371094

◆ PiInv

FP Photon.Deterministic.FP.PiInv
staticget

1/Pi.

Closest double: 0.318313598632813

◆ PiTimes2

FP Photon.Deterministic.FP.PiTimes2
staticget

2 * Pi.

Closest double: 6.28318786621094

◆ PiOver2

FP Photon.Deterministic.FP.PiOver2
staticget

Pi / 2.

Closest double: 1.57080078125

◆ PiOver2Inv

FP Photon.Deterministic.FP.PiOver2Inv
staticget

2 / Pi.

Closest double: 0.636627197265625

◆ PiOver4

FP Photon.Deterministic.FP.PiOver4
staticget

Pi / 4.

Closest double: 0.785400390625

◆ Pi3Over4

FP Photon.Deterministic.FP.Pi3Over4
staticget

3 * Pi / 4.

Closest double: 2.356201171875

◆ Pi4Over3

FP Photon.Deterministic.FP.Pi4Over3
staticget

4 * Pi / 3.

Closest double: 4.18879699707031

◆ Deg2Rad

FP Photon.Deterministic.FP.Deg2Rad
staticget

Degrees-to-radians conversion constant.

Closest double: 0.0174560546875

◆ Rad2Deg

FP Photon.Deterministic.FP.Rad2Deg
staticget

Radians-to-degrees conversion constant.

Closest double: 57.2957763671875

◆ _0

FP Photon.Deterministic.FP._0
staticget

FP constant representing the number 0.

Closest double: 0

◆ _1

FP Photon.Deterministic.FP._1
staticget

FP constant representing the number 1.

Closest double: 1

◆ _2

FP Photon.Deterministic.FP._2
staticget

FP constant representing the number 2.

Closest double: 2

◆ _3

FP Photon.Deterministic.FP._3
staticget

FP constant representing the number 3.

Closest double: 3

◆ _4

FP Photon.Deterministic.FP._4
staticget

FP constant representing the number 4.

Closest double: 4

◆ _5

FP Photon.Deterministic.FP._5
staticget

FP constant representing the number 5.

Closest double: 5

◆ _6

FP Photon.Deterministic.FP._6
staticget

FP constant representing the number 6.

Closest double: 6

◆ _7

FP Photon.Deterministic.FP._7
staticget

FP constant representing the number 7.

Closest double: 7

◆ _8

FP Photon.Deterministic.FP._8
staticget

FP constant representing the number 8.

Closest double: 8

◆ _9

FP Photon.Deterministic.FP._9
staticget

FP constant representing the number 9.

Closest double: 9

◆ _10

FP Photon.Deterministic.FP._10
staticget

FP constant representing the number 10.

Closest double: 10

◆ _99

FP Photon.Deterministic.FP._99
staticget

FP constant representing the number 99.

Closest double: 99

◆ _100

FP Photon.Deterministic.FP._100
staticget

FP constant representing the number 100.

Closest double: 100

◆ _180

FP Photon.Deterministic.FP._180
staticget

FP constant representing the number 180.

Closest double: 180

◆ _200

FP Photon.Deterministic.FP._200
staticget

FP constant representing the number 200.

Closest double: 200

◆ _360

FP Photon.Deterministic.FP._360
staticget

FP constant representing the number 360.

Closest double: 360

◆ _1000

FP Photon.Deterministic.FP._1000
staticget

FP constant representing the number 1000.

Closest double: 1000

◆ _10000

FP Photon.Deterministic.FP._10000
staticget

FP constant representing the number 10000.

Closest double: 10000

◆ _0_01

FP Photon.Deterministic.FP._0_01
staticget

FP constant representing the number 0.01.

Closest double: 0.0099945068359375

◆ _0_02

FP Photon.Deterministic.FP._0_02
staticget

FP constant representing the number 0.02.

Closest double: 0.0200042724609375

◆ _0_03

FP Photon.Deterministic.FP._0_03
staticget

FP constant representing the number 0.03.

Closest double: 0.029998779296875

◆ _0_04

FP Photon.Deterministic.FP._0_04
staticget

FP constant representing the number 0.04.

Closest double: 0.0399932861328125

◆ _0_05

FP Photon.Deterministic.FP._0_05
staticget

FP constant representing the number 0.05.

Closest double: 0.0500030517578125

◆ _0_10

FP Photon.Deterministic.FP._0_10
staticget

FP constant representing the number 0.10.

Closest double: 0.100006103515625

◆ _0_20

FP Photon.Deterministic.FP._0_20
staticget

FP constant representing the number 0.20.

Closest double: 0.199996948242188

◆ _0_25

FP Photon.Deterministic.FP._0_25
staticget

FP constant representing the number 0.25.

Closest double: 0.25

◆ _0_50

FP Photon.Deterministic.FP._0_50
staticget

FP constant representing the number 0.50.

Closest double: 0.5

◆ _0_75

FP Photon.Deterministic.FP._0_75
staticget

FP constant representing the number 0.75.

Closest double: 0.75

◆ _0_33

FP Photon.Deterministic.FP._0_33
staticget

FP constant representing the number 0.33.

Closest double: 0.333328247070313

◆ _0_99

FP Photon.Deterministic.FP._0_99
staticget

FP constant representing the number 0.99.

Closest double: 0.990005493164063

◆ Minus_1

FP Photon.Deterministic.FP.Minus_1
staticget

FP constant representing the number -1.

Closest double: -1

◆ Rad_360

FP Photon.Deterministic.FP.Rad_360
staticget

FP constant representing 360 degrees in radian.

Closest double: 6.28318786621094

◆ Rad_180

FP Photon.Deterministic.FP.Rad_180
staticget

FP constant representing 180 degrees in radian.

Closest double: 3.14158630371094

◆ Rad_90

FP Photon.Deterministic.FP.Rad_90
staticget

FP constant representing 90 degrees in radian.

Closest double: 1.57080078125

◆ Rad_45

FP Photon.Deterministic.FP.Rad_45
staticget

FP constant representing 45 degrees in radian.

Closest double: 0.785400390625

◆ Rad_22_50

FP Photon.Deterministic.FP.Rad_22_50
staticget

FP constant representing 22.5 degrees in radian.

Closest double: 0.3927001953125

◆ _1_01

FP Photon.Deterministic.FP._1_01
staticget

FP constant representing the number 1.01.

Closest double: 1.00999450683594

◆ _1_02

FP Photon.Deterministic.FP._1_02
staticget

FP constant representing the number 1.02.

Closest double: 1.02000427246094

◆ _1_03

FP Photon.Deterministic.FP._1_03
staticget

FP constant representing the number 1.03.

Closest double: 1.02999877929688

◆ _1_04

FP Photon.Deterministic.FP._1_04
staticget

FP constant representing the number 1.04.

Closest double: 1.03999328613281

◆ _1_05

FP Photon.Deterministic.FP._1_05
staticget

FP constant representing the number 1.05.

Closest double: 1.05000305175781

◆ _1_10

FP Photon.Deterministic.FP._1_10
staticget

FP constant representing the number 1.10.

Closest double: 1.10000610351563

◆ _1_20

FP Photon.Deterministic.FP._1_20
staticget

FP constant representing the number 1.20.

Closest double: 1.19999694824219

◆ _1_25

FP Photon.Deterministic.FP._1_25
staticget

FP constant representing the number 1.25.

Closest double: 1.25

◆ _1_50

FP Photon.Deterministic.FP._1_50
staticget

FP constant representing the number 1.50.

Closest double: 1.5

◆ _1_75

FP Photon.Deterministic.FP._1_75
staticget

FP constant representing the number 1.75.

Closest double: 1.75

◆ _1_33

FP Photon.Deterministic.FP._1_33
staticget

FP constant representing the number 1.33.

Closest double: 1.33332824707031

◆ _1_99

FP Photon.Deterministic.FP._1_99
staticget

FP constant representing the number 1.99.

Closest double: 1.99000549316406

◆ EN1

FP Photon.Deterministic.FP.EN1
staticget

FP constant representing the epsilon value EN1.

Closest double: 0.100006103515625

◆ EN2

FP Photon.Deterministic.FP.EN2
staticget

FP constant representing the epsilon value EN2.

Closest double: 0.0099945068359375

◆ EN3

FP Photon.Deterministic.FP.EN3
staticget

FP constant representing the epsilon value EN3.

Closest double: 0.001007080078125

◆ EN4

FP Photon.Deterministic.FP.EN4
staticget

FP constant representing the epsilon value EN4.

Closest double: 0.0001068115234375

◆ EN5

FP Photon.Deterministic.FP.EN5
staticget

FP constant representing the epsilon value EN5.

Closest double: 1.52587890625E-05

◆ Epsilon

FP Photon.Deterministic.FP.Epsilon
staticget

FP constant representing Epsilon EN3.

Closest double: 0.001007080078125

◆ E

FP Photon.Deterministic.FP.E
staticget

FP constant representing the Euler Number constant.

Closest double: 2.71827697753906

◆ Log2_E

FP Photon.Deterministic.FP.Log2_E
staticget

FP constant representing Log(E).

Closest double: 1.44268798828125

◆ Log2_10

FP Photon.Deterministic.FP.Log2_10
staticget

FP constant representing Log(10).

Closest double: 3.32192993164063

◆ AsLong

Int64 Photon.Deterministic.FP.AsLong
get

Returns integral part as long.

◆ AsInt

Int32 Photon.Deterministic.FP.AsInt
get

Return integral part as int.

◆ AsShort

Int16 Photon.Deterministic.FP.AsShort
get

Return integral part as int.

◆ AsFloat

Single Photon.Deterministic.FP.AsFloat
get

Converts to float.

◆ AsRoundedDouble

double Photon.Deterministic.FP.AsRoundedDouble
get

Converts to double. The returned value is not exact, but rather the one that has the least significant digits given FP's precision.

◆ AsDouble

Double Photon.Deterministic.FP.AsDouble
get

Converts to double.