C# 클래스 EncryptionAlgorithms.Fraction

Class name: Fraction Developed by: Syed Mehroz Alam Email: [email protected] URL: Programming Home "http://www.geocities.com/smehrozalam/" Version: 2.0 What's new in version 2.0: * Changed Numerator and Denominator from Int32(integer) to Int64(long) for increased range * renamed ConvertToString() to (overloaded) ToString() * added the capability of detecting/raising overflow exceptions * Fixed the bug that very small numbers e.g. 0.00000001 could not be converted to fraction * Other minor bugs fixed Properties: Numerator: Set/Get value for Numerator Denominator: Set/Get value for Numerator Value: Set an integer value for the fraction Constructors: no arguments: initializes fraction as 0/1 (Numerator, Denominator): initializes fraction with the given numerator and denominator values (integer): initializes fraction with the given integer value (long): initializes fraction with the given long value (double): initializes fraction with the given double value (string): initializes fraction with the given string value the string can be an in the form of and integer, double or fraction. e.g it can be like "123" or "123.321" or "123/456" Public Methods (Description is given with respective methods' definitions) (override) string ToString(Fraction) Fraction ToFraction(string) Fraction ToFraction(double) double ToDouble(Fraction) Fraction Duplicate() Fraction Inverse(integer) Fraction Inverse(Fraction) ReduceFraction(Fraction) Equals(object) GetHashCode() Private Methods (Description is given with respective methods' definitions) Initialize(Numerator, Denominator) Fraction Negate(Fraction) Fraction Add(Fraction1, Fraction2) Overloaded Operators (overloaded for Fractions, Integers and Doubles) Unary: - Binary: +,-,*,/ Relational and Logical Operators: ==,!=,<,>,<=,>= Overloaded user-defined conversions Implicit: From double/long/string to Fraction Explicit: From Fraction to double/string
파일 보기 프로젝트 열기: Omar-Salem/Classical-Encryption-Techniques 1 사용 예제들

공개 메소드들

메소드 설명
Duplicate ( ) : Fraction

The function replicates current Fraction object

Equals ( object obj ) : bool

checks whether two fractions are equal

Fraction ( ) : System

Constructors

Fraction ( double dDecimalValue ) : System
Fraction ( long iWholeNumber ) : System
Fraction ( long iNumerator, long iDenominator ) : System
Fraction ( string strValue ) : System
GetHashCode ( ) : int

returns a hash code for this fraction

Inverse ( Fraction frac1 ) : Fraction

The function returns the inverse of a Fraction object

ReduceFraction ( Fraction frac ) : void

The function reduces(simplifies) a Fraction object by dividing both its numerator and denominator by their GCD

ToDouble ( ) : double

The function returns the current Fraction object as double

ToDouble ( Fraction frac ) : double

The function takes a Fraction object and returns its value as double

ToFraction ( double dValue ) : Fraction

The function takes a floating point number as an argument and returns its corresponding reduced fraction

ToFraction ( string strValue ) : Fraction

The function takes an string as an argument and returns its corresponding reduced fraction the string can be an in the form of and integer, double or fraction. e.g it can be like "123" or "123.321" or "123/456"

ToString ( ) : string

The function returns the current Fraction object as a string

operator ( ) : Fraction
operator ( ) : bool

비공개 메소드들

메소드 설명
Add ( Fraction frac1, Fraction frac2 ) : Fraction

internal functions for binary operations

GCD ( long iNo1, long iNo2 ) : long

The function returns GCD of two numbers (used for reducing a Fraction)

Initialize ( long iNumerator, long iDenominator ) : void

Internal function for constructors

Multiply ( Fraction frac1, Fraction frac2 ) : Fraction
Negate ( Fraction frac1 ) : Fraction

internal function for negation

메소드 상세

Duplicate() 공개 메소드

The function replicates current Fraction object
public Duplicate ( ) : Fraction
리턴 Fraction

Equals() 공개 메소드

checks whether two fractions are equal
public Equals ( object obj ) : bool
obj object
리턴 bool

Fraction() 공개 메소드

Constructors
public Fraction ( ) : System
리턴 System

Fraction() 공개 메소드

public Fraction ( double dDecimalValue ) : System
dDecimalValue double
리턴 System

Fraction() 공개 메소드

public Fraction ( long iWholeNumber ) : System
iWholeNumber long
리턴 System

Fraction() 공개 메소드

public Fraction ( long iNumerator, long iDenominator ) : System
iNumerator long
iDenominator long
리턴 System

Fraction() 공개 메소드

public Fraction ( string strValue ) : System
strValue string
리턴 System

GetHashCode() 공개 메소드

returns a hash code for this fraction
public GetHashCode ( ) : int
리턴 int

Inverse() 공개 정적인 메소드

The function returns the inverse of a Fraction object
public static Inverse ( Fraction frac1 ) : Fraction
frac1 Fraction
리턴 Fraction

ReduceFraction() 공개 정적인 메소드

The function reduces(simplifies) a Fraction object by dividing both its numerator and denominator by their GCD
public static ReduceFraction ( Fraction frac ) : void
frac Fraction
리턴 void

ToDouble() 공개 메소드

The function returns the current Fraction object as double
public ToDouble ( ) : double
리턴 double

ToDouble() 공개 정적인 메소드

The function takes a Fraction object and returns its value as double
public static ToDouble ( Fraction frac ) : double
frac Fraction
리턴 double

ToFraction() 공개 정적인 메소드

The function takes a floating point number as an argument and returns its corresponding reduced fraction
public static ToFraction ( double dValue ) : Fraction
dValue double
리턴 Fraction

ToFraction() 공개 정적인 메소드

The function takes an string as an argument and returns its corresponding reduced fraction the string can be an in the form of and integer, double or fraction. e.g it can be like "123" or "123.321" or "123/456"
public static ToFraction ( string strValue ) : Fraction
strValue string
리턴 Fraction

ToString() 공개 메소드

The function returns the current Fraction object as a string
public ToString ( ) : string
리턴 string

operator() 공개 정적인 메소드

public static operator ( ) : Fraction
리턴 Fraction

operator() 공개 정적인 메소드

public static operator ( ) : bool
리턴 bool