ForgeDocs
Documentation for the forge framework
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Pages
Forge.Utilities.Real Struct Reference

A Real value implements floating point operations on the CPU. It does not adhere any any IEEE standard, but has the extremely important attribute of providing identical semantics on every CPU which executes it. This is otherwise impossible to guarantee in the CLR, especially when 3rd party code is running and/or C++ DLL access is unavailable to set x87 FPU rounding modes. More...

Public Member Functions

override bool Equals (object obj)
 
override int GetHashCode ()
 
override string ToString ()
 

Static Public Member Functions

static implicit operator Real (float value)
 
static implicit operator Real (double value)
 
static Real CreateFromRaw (long StartingRawValue)
 
static Real CreateDecimal (long beforeDecimal, int afterDecimal, int afterDigits)
 Creates a real value with that is 0.number. For example, CreateDecimal(123) will create a real value that is equal to "0.123". More...
 
static Real CreateDecimal (long beforeDecimal)
 
static Real Create (long StartingRawValue, bool UseMultiple)
 
static Real Create (double DoubleValue)
 
static Real FromParts (int PreDecimal, int PostDecimal)
 Create a fixed-int number from parts. For example, to create 1.5 pass in 1 and 500. More...
 
static Real operator* (Real one, Real other)
 
static Real operator* (Real one, int multi)
 
static Real operator* (int multi, Real one)
 
static Real operator/ (Real one, Real other)
 
static Real operator/ (Real one, int divisor)
 
static Real operator/ (int divisor, Real one)
 
static Real operator% (Real one, Real other)
 
static Real operator% (Real one, int divisor)
 
static Real operator% (int divisor, Real one)
 
static Real operator+ (Real one, Real other)
 
static Real operator+ (Real one, int other)
 
static Real operator+ (int other, Real one)
 
static Real operator- (Real a)
 
static Real operator- (Real one, Real other)
 
static Real operator- (Real one, int other)
 
static Real operator- (int other, Real one)
 
static bool operator== (Real one, Real other)
 
static bool operator== (Real one, int other)
 
static bool operator== (int other, Real one)
 
static bool operator!= (Real one, Real other)
 
static bool operator!= (Real one, int other)
 
static bool operator!= (int other, Real one)
 
static bool operator>= (Real one, Real other)
 
static bool operator>= (Real one, int other)
 
static bool operator>= (int other, Real one)
 
static bool operator<= (Real one, Real other)
 
static bool operator<= (Real one, int other)
 
static bool operator<= (int other, Real one)
 
static bool operator> (Real one, Real other)
 
static bool operator> (Real one, int other)
 
static bool operator> (int other, Real one)
 
static bool operator< (Real one, Real other)
 
static bool operator< (Real one, int other)
 
static bool operator< (int other, Real one)
 
static operator int (Real src)
 
static operator float (Real src)
 
static operator double (Real src)
 
static operator Real (int src)
 
static operator Real (long src)
 
static operator Real (ulong src)
 
static Real operator<< (Real one, int Amount)
 
static Real operator>> (Real one, int Amount)
 
static Real Sqrt (Real f, int NumberOfIterations)
 
static Real Sqrt (Real f)
 
static Real Sin (Real i)
 
static Real Cos (Real i)
 
static Real Tan (Real i)
 
static Real Asin (Real F)
 
static Real Atan (Real F)
 
static Real Atan2 (Real F1, Real F2)
 
static Real Abs (Real F)
 
static Real Floor (Real F)
 
static Real Ceiling (Real F)
 
static Real Min (Real one, Real other)
 
static Real Max (Real one, Real other)
 

Public Attributes

long RawValue
 
const int SHIFT_AMOUNT = 12
 
const long One = 1 << SHIFT_AMOUNT
 
const int OneI = 1 << SHIFT_AMOUNT
 

Static Public Attributes

static Real OneF = Real.Create(1, true)
 
static Real PI = Real.Create(12868, false)
 
static Real TwoPIF = PI * 2
 
static Real PIOver180F = PI / (Real)180
 

Properties

int AsInt [get]
 
float AsFloat [get]
 
double AsDouble [get]
 
Real Inverse [get]
 

Detailed Description

A Real value implements floating point operations on the CPU. It does not adhere any any IEEE standard, but has the extremely important attribute of providing identical semantics on every CPU which executes it. This is otherwise impossible to guarantee in the CLR, especially when 3rd party code is running and/or C++ DLL access is unavailable to set x87 FPU rounding modes.

This class has been adapted from http://stackoverflow.com/a/616015.

Member Function Documentation

static Real Forge.Utilities.Real.CreateDecimal ( long  beforeDecimal,
int  afterDecimal,
int  afterDigits 
)
static

Creates a real value with that is 0.number. For example, CreateDecimal(123) will create a real value that is equal to "0.123".

CreateDecimal(1, 0005, 4) will create 1.0005 CreateDecimal(1, 5, 4) will create 1.0005

Returns
static Real Forge.Utilities.Real.FromParts ( int  PreDecimal,
int  PostDecimal 
)
static

Create a fixed-int number from parts. For example, to create 1.5 pass in 1 and 500.

Parameters
PreDecimalThe number above the decimal. For 1.5, this would be 1.
PostDecimalThe number below the decimal, to three digits. For 1.5, this would be 500. For 1.005, this would be 5.
Returns
A fixed-int representation of the number parts

The documentation for this struct was generated from the following file: