C# 클래스 Spontaneous.DataModel.Fraction

상속: IComparable, IFormattable
파일 보기 프로젝트 열기: pashkov/Spontaneous 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
Epsilon Fraction
MaxValue Fraction
MinValue Fraction
NaN Fraction
NegativeInfinity Fraction
PositiveInfinity Fraction
Zero Fraction

Private Properties

프로퍼티 타입 설명
Add Fraction
CompareEquality bool
ConvertPositiveDouble Fraction
Fraction System
GCD long
IndeterminantCompare int
IndeterminateTypeName string
Modulus Fraction
Multiply Fraction
Negate Fraction
NormalizeIndeterminate Indeterminates
System string

공개 메소드들

메소드 설명
CompareTo ( Fraction right ) : int

Compares this Fraction to another Fraction

CompareTo ( object obj ) : int

Compares an object to this Fraction

Will convert an object from longs, doubles, and strings as this is a value-type.

CrossReducePair ( Fraction frac1, Fraction frac2 ) : void

Cross-reduces a pair of Fractions so that we have the best GCD-reduced values for multiplication

Modifies the input arguments in-place!

Equals ( object obj ) : bool

Compares for equality the current Fraction to the value passed.

Fraction ( ) : System

Default constructor; default value is NaN.

Fraction ( Fraction f ) : System

Construct a Fraction from another fraction

Fraction ( double floatingPointNumber ) : System

Construct a Fraction from a floating-point value

Fraction ( long wholeNumber ) : System

Construct a Fraction from an integral value

The denominator will be 1

Fraction ( long numerator, long denominator ) : System

Construct a Fraction from a numerator, denominator pair

Will reduce the fraction to smallest possible denominator

Fraction ( string inValue ) : System

Construct a Fraction from a string in any legal format

Will reduce the fraction to smallest possible denominator

GetHashCode ( ) : int

Returns a hash code generated from the current Fraction

Reduces (in-place) the Fraction first.

Inverse ( ) : Fraction

Inverts a Fraction

Does NOT throw for zero Numerators as later use of the fraction will catch the error.

Inverted ( double value ) : Fraction

Creates an inverted Fraction

Does NOT throw for zero Numerators as later use of the fraction will catch the error.

Inverted ( long value ) : Fraction

Creates an inverted Fraction

Does NOT throw for zero Numerators as later use of the fraction will catch the error.

IsInfinity ( ) : bool

Determines if a Fraction represents Any Infinity

IsNaN ( ) : bool

Determines if a Fraction represents a Not-a-Number

IsNegativeInfinity ( ) : bool

Determines if a Fraction represents Negative Infinity

IsPositiveInfinity ( ) : bool

Determines if a Fraction represents Positive Infinity

ReduceFraction ( Fraction frac ) : void

Reduces (simplifies) a Fraction by dividing down to lowest possible denominator (via GCD)

Modifies the input arguments in-place! Will normalize the NaN and infinites representation. Will set Denominator to 1 for any zero numerator. Moves sign to the Numerator.

ToDouble ( ) : double

Get the value of the Fraction object as double with full support for NaNs and infinities

ToFraction ( double inValue ) : Fraction

Converts a double value to the approximate Fraction

Supports double.NaN, double.PositiveInfinity and double.NegativeInfinity

ToFraction ( long inValue ) : Fraction

Converts a long value to the exact Fraction

ToFraction ( string inValue ) : Fraction

Converts a string to the corresponding reduced fraction

Four forms are supported, as a plain integer, as a double, or as Numerator/Denominator and the representations for NaN and the infinites

ToInt32 ( ) : Int32

Get the integral value of the Fraction object as int/Int32

If the value is not a true integer, the fractional part is discarded (truncated toward zero). If the valid exceeds the range of an Int32 and exception is thrown.

ToInt64 ( ) : System.Int64

Get the integral value of the Fraction object as long/Int64

If the value is not a true integer, the fractional part is discarded (truncated toward zero). If the valid exceeds the range of an Int32, no special handling is guaranteed.

ToString ( ) : string

Get the value of the Fraction as a string, with proper representation for NaNs and infinites

The current culture determines the textual representation the Indeterminates

operator ( ) : Fraction
operator ( ) : bool

비공개 메소드들

메소드 설명
Add ( Fraction left, Fraction right ) : Fraction

Adds two Fractions

CompareEquality ( Fraction right, bool notEqualCheck ) : bool

Compares for equality the current Fraction to the value passed.

ConvertPositiveDouble ( int sign, double inValue ) : Fraction
Fraction ( Indeterminates type ) : System

Private constructor to synthesize a Fraction for indeterminates (NaN and infinites)

GCD ( long left, long right ) : long

Computes the greatest common divisor for two values

IndeterminantCompare ( Indeterminates leftType, Fraction right ) : int

Determines how this Fraction, of an indeterminate type, compares to another Fraction

NaN is less than anything except NaN and Negative Infinity. Negative Infinity is less than anything except Negative Infinity. Positive Infinity is greater than anything except Positive Infinity.

IndeterminateTypeName ( long numerator ) : string

Gives the culture-related representation of the indeterminate types NaN, PositiveInfinity and NegativeInfinity

Only the sign and zero/non-zero information is relevant.

Modulus ( Fraction left, Fraction right ) : Fraction

Returns the modulus (remainder after dividing) two Fractions

Multiply ( Fraction left, Fraction right ) : Fraction

Multiplies two Fractions

Negate ( Fraction frac ) : Fraction

Negates the Fraction

NormalizeIndeterminate ( long numerator ) : Indeterminates

Gives the normalize representation of the indeterminate types NaN, PositiveInfinity and NegativeInfinity

Only the sign and zero/non-zero information is relevant.

System ( string format, IFormatProvider formatProvider ) : string

메소드 상세

CompareTo() 공개 메소드

Compares this Fraction to another Fraction
public CompareTo ( Fraction right ) : int
right Fraction The Fraction to compare against
리턴 int

CompareTo() 공개 메소드

Compares an object to this Fraction
Will convert an object from longs, doubles, and strings as this is a value-type.
public CompareTo ( object obj ) : int
obj object The object to compare against (null is less than everything)
리턴 int

CrossReducePair() 공개 정적인 메소드

Cross-reduces a pair of Fractions so that we have the best GCD-reduced values for multiplication
Modifies the input arguments in-place!
public static CrossReducePair ( Fraction frac1, Fraction frac2 ) : void
frac1 Fraction The first Fraction [WILL BE MODIFIED IN PLACE]
frac2 Fraction The second Fraction [WILL BE MODIFIED IN PLACE]
리턴 void

Equals() 공개 메소드

Compares for equality the current Fraction to the value passed.
public Equals ( object obj ) : bool
obj object A Fraction,
리턴 bool

Fraction() 공개 메소드

Default constructor; default value is NaN.
public Fraction ( ) : System
리턴 System

Fraction() 공개 메소드

Construct a Fraction from another fraction
public Fraction ( Fraction f ) : System
f Fraction
리턴 System

Fraction() 공개 메소드

Construct a Fraction from a floating-point value
public Fraction ( double floatingPointNumber ) : System
floatingPointNumber double The value
리턴 System

Fraction() 공개 메소드

Construct a Fraction from an integral value
The denominator will be 1
public Fraction ( long wholeNumber ) : System
wholeNumber long The value (eventual numerator)
리턴 System

Fraction() 공개 메소드

Construct a Fraction from a numerator, denominator pair
Will reduce the fraction to smallest possible denominator
public Fraction ( long numerator, long denominator ) : System
numerator long The numerator (top number)
denominator long The denominator (bottom number)
리턴 System

Fraction() 공개 메소드

Construct a Fraction from a string in any legal format
Will reduce the fraction to smallest possible denominator
public Fraction ( string inValue ) : System
inValue string A string with a legal fraction input format
리턴 System

GetHashCode() 공개 메소드

Returns a hash code generated from the current Fraction
Reduces (in-place) the Fraction first.
public GetHashCode ( ) : int
리턴 int

Inverse() 공개 메소드

Inverts a Fraction
Does NOT throw for zero Numerators as later use of the fraction will catch the error.
public Inverse ( ) : Fraction
리턴 Fraction

Inverted() 공개 정적인 메소드

Creates an inverted Fraction
Does NOT throw for zero Numerators as later use of the fraction will catch the error.
public static Inverted ( double value ) : Fraction
value double
리턴 Fraction

Inverted() 공개 정적인 메소드

Creates an inverted Fraction
Does NOT throw for zero Numerators as later use of the fraction will catch the error.
public static Inverted ( long value ) : Fraction
value long
리턴 Fraction

IsInfinity() 공개 메소드

Determines if a Fraction represents Any Infinity
public IsInfinity ( ) : bool
리턴 bool

IsNaN() 공개 메소드

Determines if a Fraction represents a Not-a-Number
public IsNaN ( ) : bool
리턴 bool

IsNegativeInfinity() 공개 메소드

Determines if a Fraction represents Negative Infinity
public IsNegativeInfinity ( ) : bool
리턴 bool

IsPositiveInfinity() 공개 메소드

Determines if a Fraction represents Positive Infinity
public IsPositiveInfinity ( ) : bool
리턴 bool

ReduceFraction() 공개 정적인 메소드

Reduces (simplifies) a Fraction by dividing down to lowest possible denominator (via GCD)
Modifies the input arguments in-place! Will normalize the NaN and infinites representation. Will set Denominator to 1 for any zero numerator. Moves sign to the Numerator.
public static ReduceFraction ( Fraction frac ) : void
frac Fraction The Fraction to be reduced [WILL BE MODIFIED IN PLACE]
리턴 void

ToDouble() 공개 메소드

Get the value of the Fraction object as double with full support for NaNs and infinities
public ToDouble ( ) : double
리턴 double

ToFraction() 공개 정적인 메소드

Converts a double value to the approximate Fraction
Supports double.NaN, double.PositiveInfinity and double.NegativeInfinity
public static ToFraction ( double inValue ) : Fraction
inValue double The double to convert
리턴 Fraction

ToFraction() 공개 정적인 메소드

Converts a long value to the exact Fraction
public static ToFraction ( long inValue ) : Fraction
inValue long The long to convert
리턴 Fraction

ToFraction() 공개 정적인 메소드

Converts a string to the corresponding reduced fraction
Four forms are supported, as a plain integer, as a double, or as Numerator/Denominator and the representations for NaN and the infinites
public static ToFraction ( string inValue ) : Fraction
inValue string The string representation of a fractional value
리턴 Fraction

ToInt32() 공개 메소드

Get the integral value of the Fraction object as int/Int32
If the value is not a true integer, the fractional part is discarded (truncated toward zero). If the valid exceeds the range of an Int32 and exception is thrown.
Will throw a FractionException for NaN, PositiveInfinity /// or NegativeInfinity with the InnerException set to a System.NotFiniteNumberException.
public ToInt32 ( ) : Int32
리턴 System.Int32

ToInt64() 공개 메소드

Get the integral value of the Fraction object as long/Int64
If the value is not a true integer, the fractional part is discarded (truncated toward zero). If the valid exceeds the range of an Int32, no special handling is guaranteed.
Will throw a FractionException for NaN, PositiveInfinity /// or NegativeInfinity with the InnerException set to a System.NotFiniteNumberException.
public ToInt64 ( ) : System.Int64
리턴 System.Int64

ToString() 공개 메소드

Get the value of the Fraction as a string, with proper representation for NaNs and infinites
The current culture determines the textual representation the Indeterminates
public ToString ( ) : string
리턴 string

operator() 공개 정적인 메소드

public static operator ( ) : Fraction
리턴 Fraction

operator() 공개 정적인 메소드

public static operator ( ) : bool
리턴 bool

프로퍼티 상세

Epsilon 공개적으로 정적으로 프로퍼티

public static Fraction,Spontaneous.DataModel Epsilon
리턴 Fraction

MaxValue 공개적으로 정적으로 프로퍼티

public static Fraction,Spontaneous.DataModel MaxValue
리턴 Fraction

MinValue 공개적으로 정적으로 프로퍼티

public static Fraction,Spontaneous.DataModel MinValue
리턴 Fraction

NaN 공개적으로 정적으로 프로퍼티

public static Fraction,Spontaneous.DataModel NaN
리턴 Fraction

NegativeInfinity 공개적으로 정적으로 프로퍼티

public static Fraction,Spontaneous.DataModel NegativeInfinity
리턴 Fraction

PositiveInfinity 공개적으로 정적으로 프로퍼티

public static Fraction,Spontaneous.DataModel PositiveInfinity
리턴 Fraction

Zero 공개적으로 정적으로 프로퍼티

public static Fraction,Spontaneous.DataModel Zero
리턴 Fraction