|
|
|
Click here to copy the following block |
Sub DecToFrac(DecimalNum As Double, Numerator As Long, Denom As Long)
Const BigNumber = 50000 Const SmallNumber = 1E-16
Dim Inverse As Double, FractionalPart As Double Dim WholePart As Long, SwapTemp As Long
Inverse = 1 / DecimalNum WholePart = Int(Inverse) FractionalPart = Frac(Inverse)
If 1 / (FractionalPart + SmallNumber) < BigNumber Then Call DecToFrac(FractionalPart, Numerator, Denom) Numerator = Denom * WholePart + Numerator
SwapTemp = Numerator Numerator = Denom Denom = SwapTemp Else Numerator = 1 Denom = Int(Inverse) End If End Sub
Function Frac(x As Double) As Double Frac = Abs(Abs(x) - Int(Abs(x))) End Function
Sub DecToProperFrac(x As Double, a As Long, b As Long, c As Long) If x > 1 Then a = Int(x) If Frac(x) <> 0 Then Call DecToFrac(Frac(x), b, c) End If End Sub |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|