Public Function RationalToFraction( _
ByRef rNumber As Variant _
, ByRef rDividend As Variant _
, ByRef rDivisor As Variant _
, ByVal vRational As Variant _
) As Boolean
"Rational Number To Fractional Components" Example:
Converts vRational to X+Y/Z (where X, Y, and X are all integers) then returns X, Y, and Z via arguments.
Function returns True upon success and False upon failure.
Dim varI As Variant
Dim varX As Variant
Dim varY As Variant
RationalToFraction(varI, varX, varY, -43.75) = True
varI = -43
varX = -3
varY = 4See also:
GreatestCommonDivisor FunctionrNumber: Numeric or Variant argument through which the integer part of vRational is returned.
rDividend: Numeric or Variant argument through which the dividend of the fractional part of vRational is returned. Note: When vRational is an integer, this function returns a dividend of 0 (zero). Note: When vRational is negative, the dividend returned by this function will be negative.
rDivisor: Numeric or Variant argument through which the divisor of the fractional part of vRational is returned. Note: When vRational is an integer, this function returns a divisor of 1 (one). Note: This function will always return a positive divisor, even if vRational is negative.
vRational: The number which is separated into its integer, fractional dividend, and fractional divisor parts. Function returns Null if vRational is Null or cannot be fixed up to a number.
Note: One use of this function is to back-track from rational stock prices like 9.375 into a number like 9+3/8.
Note: Accuracy is between 12 and 14 digits.
Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.