Signature (Visual Basic / VBA)
Public Function RationalToFraction( _
ByRef rNumber As Variant _
, ByRef rDividend As Variant _
, ByRef rDivisor As Variant _
, ByVal vRational As Variant _
) As Boolean
Code Example
Assuming
Dim varI As Variant
Dim varX As Variant
Dim varY As Variant
for example
RationalToFraction(varI, varX, varY, -43.75) = True
leaves
varI = -43
varX = -3
varY = 4
Parameters
| Parameter | Description |
|---|---|
| rNumber | 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. |
Notes & Version History
| 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. |